from collections import deque



n = int(eval(input()))

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

if 1 in a:

    count = 0

    num = 1

    for i in a:

        if num == i:

            num += 1

        else:

            count += 1

    print(count)

else:

    print((-1))



n = int(eval(input()))

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



i = 1

ans = 0

red = []

for a in A:

    if a == i:

        red += [i]

        i += 1

    else:

        ans += 1

if not ans == len(A):

    print(ans)

else:

    print((-1))
from collections import deque

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

n = int(eval(input()))
A = list(map(int, input().split()))
i = 1
ans = 0
red = []
for a in A:
    if a == i:
        red += [i]
        i += 1
    else:
        ans += 1
if not ans == len(A):
    print(ans)
else:
    print((-1))

-from collections import deque - -a = list(map(int, input().split())) -if 1 in a: -    count = 0 -    num = 1 -    for i in a: -        if num == i: -            num += 1 -        else: -            count += 1 -    print(count) +A = list(map(int, input().split())) +i = 1 +ans = 0 +red = [] +for a in A: +    if a == i: +        red += [i] +        i += 1 +    else: +        ans += 1 +if not ans == len(A): +    print(ans)