n=int(eval(input()))

*A,=list(map(int,input().split()))



if 1 not in A:

      print((-1))

      exit()



c=1

for i in range(n):

      if c==A[i]:

            c+=1

print((len(A)-(c-1)))
n=int(eval(input()))

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



if 1 not in A:

    print((-1))

    exit()

bef=1

ans=0

for i in A:

    if i==bef:

        bef+=1

    else:

        ans+=1

print(ans)

        
n = int(eval(input()))
(*A,) = list(map(int, input().split()))
if 1 not in A:
    print((-1))
    exit()
c = 1
for i in range(n):
    if c == A[i]:
        c += 1
print((len(A) - (c - 1)))

n = int(eval(input()))
A = list(map(int, input().split()))
if 1 not in A:
    print((-1))
    exit()
bef = 1
ans = 0
for i in A:
    if i == bef:
        bef += 1
    else:
        ans += 1
print(ans)

-(*A,) = list(map(int, input().split())) +A = list(map(int, input().split())) -c = 1 -for i in range(n): -    if c == A[i]: -        c += 1 -print((len(A) - (c - 1))) +bef = 1 +ans = 0 +for i in A: +    if i == bef: +        bef += 1 +    else: +        ans += 1 +print(ans)