n = int(eval(input()))

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



now = 1

ans = 0

for i in range(n):

    if a[i] == now:

        now += 1

    else:

        ans += 1



if ans == len(a):

    print((-1))

else:

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

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



val = 1

ans = 0

for a_i in a:

    if a_i == val:

        val += 1

    else:

        ans += 1



if val == 1:

    print((-1))

else:

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

n = int(eval(input()))
a = list(map(int, input().split()))
val = 1
ans = 0
for a_i in a:
    if a_i == val:
        val += 1
    else:
        ans += 1
if val == 1:
    print((-1))
else:
    print(ans)

-now = 1 +val = 1 -for i in range(n): -    if a[i] == now: -        now += 1 +for a_i in a: +    if a_i == val: +        val += 1 -if ans == len(a): +if val == 1: