n = int(eval(input()))

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

cur = 0

cnt = 0

for v in a:

  if v == cur+1:

    cur = v

    cnt += 1

if cnt==0:

  print((-1))

else:

  print((len(a)-cnt))
n = int(eval(input()))

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

cnt = 0

for v in a:

  if v == cnt+1:

    cnt += 1

print((-1 if cnt==0 else n-cnt))
n = int(eval(input()))
a = list(map(int, input().split()))
cur = 0
cnt = 0
for v in a:
    if v == cur + 1:
        cur = v
        cnt += 1
if cnt == 0:
    print((-1))
else:
    print((len(a) - cnt))

n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 0
for v in a:
    if v == cnt + 1:
        cnt += 1
print((-1 if cnt == 0 else n - cnt))

-cur = 0 -    if v == cur + 1: -        cur = v +    if v == cnt + 1: -if cnt == 0: -    print((-1)) -else: -    print((len(a) - cnt)) +print((-1 if cnt == 0 else n - cnt))