N = int(eval(input()))

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



se = 1

for i in range(N):

    if A[i]==se:

        se+=1



ans=N-se+1

if se==1:

    ans=-1

print(ans)
import sys

input = sys.stdin.readline



def I(): return int(eval(input()))

def MI(): return list(map(int, input().split()))

def LI(): return list(map(int, input().split()))



def main():

    mod=10**9+7

    N=I()

    A=LI()

    cnt=0

    now=1

    

    for i in range(N):

        if A[i]==now:

            now+=1

        else:

            cnt+=1

            

    if cnt==N:

        cnt=-1

    print(cnt)

        



main()

N = int(eval(input()))
A = list(map(int, input().split()))
se = 1
for i in range(N):
    if A[i] == se:
        se += 1
ans = N - se + 1
if se == 1:
    ans = -1
print(ans)

import sys

input = sys.stdin.readline


def I():
    return int(eval(input()))


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


def main():
    mod = 10**9 + 7
    N = I()
    A = LI()
    cnt = 0
    now = 1
    for i in range(N):
        if A[i] == now:
            now += 1
        else:
            cnt += 1
    if cnt == N:
        cnt = -1
    print(cnt)


main()

-N = int(eval(input())) -A = list(map(int, input().split())) -se = 1 -for i in range(N): -    if A[i] == se: -        se += 1 -ans = N - se + 1 -if se == 1: -    ans = -1 -print(ans) +import sys + +input = sys.stdin.readline + + +def I(): +    return int(eval(input())) + + +def MI(): +    return list(map(int, input().split())) + + +def LI(): +    return list(map(int, input().split())) + + +def main(): +    mod = 10**9 + 7 +    N = I() +    A = LI() +    cnt = 0 +    now = 1 +    for i in range(N): +        if A[i] == now: +            now += 1 +        else: +            cnt += 1 +    if cnt == N: +        cnt = -1 +    print(cnt) + + +main()