N, *A = list(map(int, open(0).read().split()))



cnt = 0

ans = 0

for i in range(N):

    if cnt + 1 == A[i]:

        cnt += 1

    else:

        ans += 1



if ans == N:

    print((-1))

else:

    print(ans)

N, *A = list(map(int, open(0).read().split()))



cur = 0

for i in range(N):

    if A[i] == cur + 1:

        cur += 1



if cur == 0:

    print((-1))

else:

    print((N - cur))

N, *A = list(map(int, open(0).read().split()))
cnt = 0
ans = 0
for i in range(N):
    if cnt + 1 == A[i]:
        cnt += 1
    else:
        ans += 1
if ans == N:
    print((-1))
else:
    print(ans)

N, *A = list(map(int, open(0).read().split()))
cur = 0
for i in range(N):
    if A[i] == cur + 1:
        cur += 1
if cur == 0:
    print((-1))
else:
    print((N - cur))

-cnt = 0 -ans = 0 +cur = 0 -    if cnt + 1 == A[i]: -        cnt += 1 -    else: -        ans += 1 -if ans == N: +    if A[i] == cur + 1: +        cur += 1 +if cur == 0: -    print(ans) +    print((N - cur))