N = int(eval(input()))

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

if l == [i+1 for i in range(N)]: # 1, 2, 3, ...

  print((0))

elif 1 not in l:

  print((-1))

else:

  detected = 0

  target = 1

  for i in l:

    if i == target:

      detected += 1

      target += 1

  

  print((N - detected))
N = int(eval(input()))

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

if 1 not in l:

  print((-1))

else:

  detected = 0

  for i in l:

    if i == detected+1:

      detected += 1

  

  print((N - detected))
N = int(eval(input()))
l = list(map(int, input().split()))
if l == [i + 1 for i in range(N)]:  # 1, 2, 3, ...
    print((0))
elif 1 not in l:
    print((-1))
else:
    detected = 0
    target = 1
    for i in l:
        if i == target:
            detected += 1
            target += 1
    print((N - detected))

N = int(eval(input()))
l = list(map(int, input().split()))
if 1 not in l:
    print((-1))
else:
    detected = 0
    for i in l:
        if i == detected + 1:
            detected += 1
    print((N - detected))

-if l == [i + 1 for i in range(N)]:  # 1, 2, 3, ... -    print((0)) -elif 1 not in l: +if 1 not in l: -    target = 1 -        if i == target: +        if i == detected + 1: -            target += 1