n = int(eval(input()))

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

cnt = 1

ans = 0



for i in range(n):

    if a[i] != cnt:

        ans += 1

    else:

        cnt += 1



if ans == n:

    print((-1))

else:

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

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

ans = 0

cnt = 1



for i in a:

    if cnt == i:

        cnt += 1

    else:

        ans += 1

if ans == n:

    print((-1))

else:

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

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

+ans = 0 -ans = 0 -for i in range(n): -    if a[i] != cnt: +for i in a: +    if cnt == i: +        cnt += 1 +    else: -    else: -        cnt += 1