N=int(eval(input()))

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

tar=1

found=0

for i in range(len(a)):

  if a[i]==tar:

    tar+=1

    found+=1

if found==0:

  print((-1))

else:

  print((N-found))
N=int(eval(input()))

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

t=0

for i in range(N):

  if A[i]==t+1:

    t+=1

print(((-1,N-t)[t>0]))
N = int(eval(input()))
a = list(map(int, input().split()))
tar = 1
found = 0
for i in range(len(a)):
    if a[i] == tar:
        tar += 1
        found += 1
if found == 0:
    print((-1))
else:
    print((N - found))

N = int(eval(input()))
A = list(map(int, input().split()))
t = 0
for i in range(N):
    if A[i] == t + 1:
        t += 1
print(((-1, N - t)[t > 0]))

-a = list(map(int, input().split())) -tar = 1 -found = 0 -for i in range(len(a)): -    if a[i] == tar: -        tar += 1 -        found += 1 -if found == 0: -    print((-1)) -else: -    print((N - found)) +A = list(map(int, input().split())) +t = 0 +for i in range(N): +    if A[i] == t + 1: +        t += 1 +print(((-1, N - t)[t > 0]))