n = int(eval(input()))

a = [int(i) for i in input().split()]

if 1 in a:

    j = 0

    for ai in a:

        if ai == j + 1:

            j += 1

    print((n - j))

else:

    print((-1))
n,a=open(0);j=0

for b in map(int,a.split()):

    if b==j+1:j+=1

print(([-1,int(n)-j][j>0]))
n = int(eval(input()))
a = [int(i) for i in input().split()]
if 1 in a:
    j = 0
    for ai in a:
        if ai == j + 1:
            j += 1
    print((n - j))
else:
    print((-1))

n, a = open(0)
j = 0
for b in map(int, a.split()):
    if b == j + 1:
        j += 1
print(([-1, int(n) - j][j > 0]))

-n = int(eval(input())) -a = [int(i) for i in input().split()] -if 1 in a: -    j = 0 -    for ai in a: -        if ai == j + 1: -            j += 1 -    print((n - j)) -else: -    print((-1)) +n, a = open(0) +j = 0 +for b in map(int, a.split()): +    if b == j + 1: +        j += 1 +print(([-1, int(n) - j][j > 0]))