from collections import deque

n = int(eval(input()))

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



next_ = 1

cnt = 0

for i in A:

  if i == next_:

    next_ += 1

  else:

    cnt += 1

if cnt == n:

  cnt = -1

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

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



next_ = 1

cnt = 0

for i in A:

  if i == next_:

    next_ += 1

  else:

    cnt += 1

if cnt == n:

  cnt = -1

print(cnt)
from collections import deque

n = int(eval(input()))
A = deque(list(map(int, input().split())))
next_ = 1
cnt = 0
for i in A:
    if i == next_:
        next_ += 1
    else:
        cnt += 1
if cnt == n:
    cnt = -1
print(cnt)

n = int(eval(input()))
A = list(map(int, input().split()))
next_ = 1
cnt = 0
for i in A:
    if i == next_:
        next_ += 1
    else:
        cnt += 1
if cnt == n:
    cnt = -1
print(cnt)

-from collections import deque - -A = deque(list(map(int, input().split()))) +A = list(map(int, input().split()))