n=int(eval(input()))



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



res = 0



count = 1



for i in t:

    if i == count:

        count += 1

        res += 1

if res == 0:

    print((-1))

else:

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



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



if 1 in t:

    ans = 0

else:

    print((-1))

    exit()



for i in range(n):

    if t[i] == ans+1:

        ans += 1

print((n-ans))

    
n = int(eval(input()))
t = list(map(int, input().split()))
res = 0
count = 1
for i in t:
    if i == count:
        count += 1
        res += 1
if res == 0:
    print((-1))
else:
    print((n - res))

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

-res = 0 -count = 1 -for i in t: -    if i == count: -        count += 1 -        res += 1 -if res == 0: +if 1 in t: +    ans = 0 +else: -else: -    print((n - res)) +    exit() +for i in range(n): +    if t[i] == ans + 1: +        ans += 1 +print((n - ans))