n = int(eval(input()))

a_inputs = [int(i) for i in input().split()]



a_only = list(set(a_inputs))



ans=0

count=0

for i in range(len(a_inputs)):

    if a_inputs[i]==(count+1):

        count+=1

        continue

    else:

        ans+=1



if a_inputs==a_only:

    print((0))

elif 1 not in a_inputs:

    print((-1))

else:

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

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



if 1 not in A:

    print((-1));exit()



tmp=0

for i in range(n):

    if A[i]==tmp+1:

        tmp+=1

print((n-tmp))
n = int(eval(input()))
a_inputs = [int(i) for i in input().split()]
a_only = list(set(a_inputs))
ans = 0
count = 0
for i in range(len(a_inputs)):
    if a_inputs[i] == (count + 1):
        count += 1
        continue
    else:
        ans += 1
if a_inputs == a_only:
    print((0))
elif 1 not in a_inputs:
    print((-1))
else:
    print(ans)

n = int(eval(input()))
A = list(map(int, input().split()))
if 1 not in A:
    print((-1))
    exit()
tmp = 0
for i in range(n):
    if A[i] == tmp + 1:
        tmp += 1
print((n - tmp))

-a_inputs = [int(i) for i in input().split()] -a_only = list(set(a_inputs)) -ans = 0 -count = 0 -for i in range(len(a_inputs)): -    if a_inputs[i] == (count + 1): -        count += 1 -        continue -    else: -        ans += 1 -if a_inputs == a_only: -    print((0)) -elif 1 not in a_inputs: +A = list(map(int, input().split())) +if 1 not in A: -else: -    print(ans) +    exit() +tmp = 0 +for i in range(n): +    if A[i] == tmp + 1: +        tmp += 1 +print((n - tmp))