# coding: utf-8

N = int(eval(input()))

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

if 1 not in A:

    print((-1))

    exit()



target = 1

idx = 0

ans = 0

while idx < len(A):

    if A[idx] == target:

        target += 1

        ans += 1

    idx += 1

print((N - ans))
# coding: utf-8

N = int(eval(input()))

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

l = [0]

ans = 0

for i in range(N):

    if l[-1] + 1 != A[i]:

        ans += 1

    else:

        l.append(A[i])

if l[-1] == 0:

    print((-1))

else:

    print(ans)
# coding: utf-8
N = int(eval(input()))
A = list(map(int, input().split()))
if 1 not in A:
    print((-1))
    exit()
target = 1
idx = 0
ans = 0
while idx < len(A):
    if A[idx] == target:
        target += 1
        ans += 1
    idx += 1
print((N - ans))

# coding: utf-8
N = int(eval(input()))
A = list(map(int, input().split()))
l = [0]
ans = 0
for i in range(N):
    if l[-1] + 1 != A[i]:
        ans += 1
    else:
        l.append(A[i])
if l[-1] == 0:
    print((-1))
else:
    print(ans)

-if 1 not in A: +l = [0] +ans = 0 +for i in range(N): +    if l[-1] + 1 != A[i]: +        ans += 1 +    else: +        l.append(A[i]) +if l[-1] == 0: -    exit() -target = 1 -idx = 0 -ans = 0 -while idx < len(A): -    if A[idx] == target: -        target += 1 -        ans += 1 -    idx += 1 -print((N - ans)) +else: +    print(ans)