n=int(eval(input()))

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



bef=1

ans=0



if 1 not in A:

    print((-1))

    exit()



for i in range(n):

    if A[i]==bef:

        bef+=1

        ans+=1

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

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



if 1 not in A:

    print((-1))

    exit()

s=1

for i in range(n):

    if A[i]==s:

        s+=1

print((n-(s-1)))

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

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

-bef = 1 -ans = 0 +s = 1 -    if A[i] == bef: -        bef += 1 -        ans += 1 -print((n - ans)) +    if A[i] == s: +        s += 1 +print((n - (s - 1)))