n = int(eval(input()))

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



t = 1

ans = 0

for i in range(n):

  if t != a[i]:

    ans += 1

    a[i] = -1

  else:

    t += 1



if all([i == -1 for i in a]):

  print((-1))

else:

  print(ans)
n = int(eval(input()))

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



ans = 0

t = 1

s = []

for i in a:

  if i != t: ans += 1

  else:

    t += 1

    s.append(i)



if s == []:

  print((-1))

else:

  print(ans)
n = int(eval(input()))
a = list(map(int, input().split()))
t = 1
ans = 0
for i in range(n):
    if t != a[i]:
        ans += 1
        a[i] = -1
    else:
        t += 1
if all([i == -1 for i in a]):
    print((-1))
else:
    print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
t = 1
s = []
for i in a:
    if i != t:
        ans += 1
    else:
        t += 1
        s.append(i)
if s == []:
    print((-1))
else:
    print(ans)

+ans = 0 -ans = 0 -for i in range(n): -    if t != a[i]: +s = [] +for i in a: +    if i != t: -        a[i] = -1 -if all([i == -1 for i in a]): +        s.append(i) +if s == []: