n = int(eval(input()))

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



start = 1

i = 0

while i < n:

    if a[i] == start:

        start += 1

        i += 1

    else:

        i += 1



start -= 1



if start == 0:

    print((-1))

else:

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

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



v = 1

for a in A:

    if a == v:

        v += 1



print((-1 if v==1 else n-v+1))
n = int(eval(input()))
a = list(map(int, input().split()))
start = 1
i = 0
while i < n:
    if a[i] == start:
        start += 1
        i += 1
    else:
        i += 1
start -= 1
if start == 0:
    print((-1))
else:
    print((n - start))

n = int(eval(input()))
A = list(map(int, input().split()))
v = 1
for a in A:
    if a == v:
        v += 1
print((-1 if v == 1 else n - v + 1))

-a = list(map(int, input().split())) -start = 1 -i = 0 -while i < n: -    if a[i] == start: -        start += 1 -        i += 1 -    else: -        i += 1 -start -= 1 -if start == 0: -    print((-1)) -else: -    print((n - start)) +A = list(map(int, input().split())) +v = 1 +for a in A: +    if a == v: +        v += 1 +print((-1 if v == 1 else n - v + 1))