N = int(eval(input()))

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



A = []

i = 1

j = 0

while j != N:

    if a[j] == i:

        i += 1

    j += 1

else:

    if i == 1:

        print((-1))

    else:

        print((N-(i-1)))
N = int(eval(input()))

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



i = 0

for j in range(N):

    if a[j] == i+1:

        i += 1

else:

    if i == 0:

        print((-1))

    else:

        print((N-i))

N = int(eval(input()))
a = list(map(int, input().split()))
A = []
i = 1
j = 0
while j != N:
    if a[j] == i:
        i += 1
    j += 1
else:
    if i == 1:
        print((-1))
    else:
        print((N - (i - 1)))

N = int(eval(input()))
a = list(map(int, input().split()))
i = 0
for j in range(N):
    if a[j] == i + 1:
        i += 1
else:
    if i == 0:
        print((-1))
    else:
        print((N - i))

-A = [] -i = 1 -j = 0 -while j != N: -    if a[j] == i: +i = 0 +for j in range(N): +    if a[j] == i + 1: -    j += 1 -    if i == 1: +    if i == 0: -        print((N - (i - 1))) +        print((N - i))