n = int(eval(input()))

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

num = 1

for i in an:

    if i == num:

        num +=1

if num == 1:

    print((-1))

    exit(0)

ans = 1+n-num

print(ans)
import sys

n = int(eval(input()))

a = list(map(int, sys.stdin.readline().split()))

m = 1

for i in a:

    if i == m:

        m += 1

if m == 1:

    print((-1))

    exit(0)

print((1+n-m))
n = int(eval(input()))
an = list(map(int, input().split()))
num = 1
for i in an:
    if i == num:
        num += 1
if num == 1:
    print((-1))
    exit(0)
ans = 1 + n - num
print(ans)

import sys

n = int(eval(input()))
a = list(map(int, sys.stdin.readline().split()))
m = 1
for i in a:
    if i == m:
        m += 1
if m == 1:
    print((-1))
    exit(0)
print((1 + n - m))

+import sys + -an = list(map(int, input().split())) -num = 1 -for i in an: -    if i == num: -        num += 1 -if num == 1: +a = list(map(int, sys.stdin.readline().split())) +m = 1 +for i in a: +    if i == m: +        m += 1 +if m == 1: -ans = 1 + n - num -print(ans) +print((1 + n - m))