n = int(eval(input()))

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



ans = 0

current = 1

for i in range(n):

    if a[i] != current:

        ans += 1

        continue



    current += 1



print((-1 if ans == n else ans))

n = int(eval(input()))

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



cur = 1

ans = 0

for _a in a:

    if _a == cur:

        cur += 1

    else:

        ans += 1



print((-1 if ans == n else ans))

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

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

+cur = 1 -current = 1 -for i in range(n): -    if a[i] != current: +for _a in a: +    if _a == cur: +        cur += 1 +    else: -        continue -    current += 1