N = int(eval(input()))

a = [int(s) - 1 for s in input().split()]



result = 0

for i in range(N):

  if a[i] != (i - result):

    result += 1

if result == N:

  print((-1))

else:

  print(result)

N = int(eval(input()))



t = 1

result = 0

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

    if a == t:

        t += 1

    else:

        result += 1



if result == N:

    print((-1))

else:

    print(result)

N = int(eval(input()))
a = [int(s) - 1 for s in input().split()]
result = 0
for i in range(N):
    if a[i] != (i - result):
        result += 1
if result == N:
    print((-1))
else:
    print(result)

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

-a = [int(s) - 1 for s in input().split()] +t = 1 -for i in range(N): -    if a[i] != (i - result): +for a in map(int, input().split()): +    if a == t: +        t += 1 +    else: