def solve():

    l=[0]

    count=0

    for i in a:

        if i==l[-1]+1:

            l+=[i]

        else:

            count+=1

    print((count if len(l)!=1 else -1))



n=int(eval(input()))

a=list(map(int,input().split()))

solve()
n = int(eval(input()))

a = list(map(int,input().split()))



cnt = 0

num = 1

for i in range(n):

    if a[i] != num:

        cnt += 1

        continue

    num += 1

print((cnt if cnt != n else -1))
def solve():
    l = [0]
    count = 0
    for i in a:
        if i == l[-1] + 1:
            l += [i]
        else:
            count += 1
    print((count if len(l) != 1 else -1))


n = int(eval(input()))
a = list(map(int, input().split()))
solve()

n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 0
num = 1
for i in range(n):
    if a[i] != num:
        cnt += 1
        continue
    num += 1
print((cnt if cnt != n else -1))

-def solve(): -    l = [0] -    count = 0 -    for i in a: -        if i == l[-1] + 1: -            l += [i] -        else: -            count += 1 -    print((count if len(l) != 1 else -1)) - - -solve() +cnt = 0 +num = 1 +for i in range(n): +    if a[i] != num: +        cnt += 1 +        continue +    num += 1 +print((cnt if cnt != n else -1))