n = int(eval(input()))

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

x = [i for i in range(1,2000001)]

ans = 0

cnt = 0

if 1 not in a:

    print((-1))

    quit()

for i in range(n):

    if x[cnt] != a[i]:

        ans += 1

    else:

        cnt += 1

print(ans)

n = int(eval(input()))

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

ans = 0

cnt = 1

if 1 not in a:

    print((-1))

    quit()

for i in range(n):

    if cnt == a[i]:

        cnt += 1

    else:

        ans += 1

print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
x = [i for i in range(1, 2000001)]
ans = 0
cnt = 0
if 1 not in a:
    print((-1))
    quit()
for i in range(n):
    if x[cnt] != a[i]:
        ans += 1
    else:
        cnt += 1
print(ans)

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

-x = [i for i in range(1, 2000001)] -cnt = 0 +cnt = 1 -    if x[cnt] != a[i]: +    if cnt == a[i]: +        cnt += 1 +    else: -    else: -        cnt += 1