n = int(eval(input()))

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



num_looking_for = 1

index = 0

cnt = 0



while index < n:

    if a[index] == num_looking_for:

        num_looking_for += 1

    else:

        cnt += 1

    index += 1



if cnt == n:

    print((-1))

    quit()

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

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



num_looking_for = 1

cnt = 0

for i in range(n):

    if a[i] == num_looking_for:

        num_looking_for += 1

    else:

        cnt += 1

print(("-1" if cnt == n else cnt))
n = int(eval(input()))
a = list(map(int, input().split()))
num_looking_for = 1
index = 0
cnt = 0
while index < n:
    if a[index] == num_looking_for:
        num_looking_for += 1
    else:
        cnt += 1
    index += 1
if cnt == n:
    print((-1))
    quit()
print(cnt)

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

-index = 0 -while index < n: -    if a[index] == num_looking_for: +for i in range(n): +    if a[i] == num_looking_for: -    index += 1 -if cnt == n: -    print((-1)) -    quit() -print(cnt) +print(("-1" if cnt == n else cnt))