N = int(eval(input()))

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



pos = 1

for a in A:

    if a == pos:

        pos += 1



if pos == 1:

    print((-1))

else:

    print((N - pos + 1))

N = int(eval(input()))

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



k = 1

cnt = 0

for a in A:

    if a == k:

        cnt += 1

        k += 1



ans = -1 if k == 1 else N - cnt

print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
pos = 1
for a in A:
    if a == pos:
        pos += 1
if pos == 1:
    print((-1))
else:
    print((N - pos + 1))

N = int(eval(input()))
A = list(map(int, input().split()))
k = 1
cnt = 0
for a in A:
    if a == k:
        cnt += 1
        k += 1
ans = -1 if k == 1 else N - cnt
print(ans)

-pos = 1 +k = 1 +cnt = 0 -    if a == pos: -        pos += 1 -if pos == 1: -    print((-1)) -else: -    print((N - pos + 1)) +    if a == k: +        cnt += 1 +        k += 1 +ans = -1 if k == 1 else N - cnt +print(ans)