n = int(eval(input()))

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



if 1 not in a:

    print((-1))

    exit()



now = 1

ans = 0

for i in a:

    if i != now:

        ans += 1

    else:

        now += 1



print(ans)
n = int(eval(input()))

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



cnt = 0

now = 1

for i, v in enumerate(a):

    if v == now:

        now += 1

        continue

    else:

        cnt += 1



print((cnt if cnt != len(a) else -1))
n = int(eval(input()))
a = list(map(int, input().split()))
if 1 not in a:
    print((-1))
    exit()
now = 1
ans = 0
for i in a:
    if i != now:
        ans += 1
    else:
        now += 1
print(ans)

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

-if 1 not in a: -    print((-1)) -    exit() +cnt = 0 -ans = 0 -for i in a: -    if i != now: -        ans += 1 +for i, v in enumerate(a): +    if v == now: +        now += 1 +        continue -        now += 1 -print(ans) +        cnt += 1 +print((cnt if cnt != len(a) else -1))