import math

import itertools



N = int(eval(input()))

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

mark = 0

for a in A:

  if a == mark+1:

    mark += 1

if mark == 0:

  print((-1))

else:

  print((N-mark))
def solve():

  N = int(eval(input()))

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

  ans = 0

  p = 1

  for a in A:

    if a==p:

      p += 1

    else:

      ans += 1

  if p==1:

    ans = -1

  return ans

print((solve()))
import math
import itertools

N = int(eval(input()))
A = list(map(int, input().split()))
mark = 0
for a in A:
    if a == mark + 1:
        mark += 1
if mark == 0:
    print((-1))
else:
    print((N - mark))

def solve():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    ans = 0
    p = 1
    for a in A:
        if a == p:
            p += 1
        else:
            ans += 1
    if p == 1:
        ans = -1
    return ans


print((solve()))

-import math -import itertools +def solve(): +    N = int(eval(input())) +    A = list(map(int, input().split())) +    ans = 0 +    p = 1 +    for a in A: +        if a == p: +            p += 1 +        else: +            ans += 1 +    if p == 1: +        ans = -1 +    return ans -N = int(eval(input())) -A = list(map(int, input().split())) -mark = 0 -for a in A: -    if a == mark + 1: -        mark += 1 -if mark == 0: -    print((-1)) -else: -    print((N - mark)) + +print((solve()))