n = int(eval(input()))

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

i = k = 0

try:

  while True:

    i = a.index(k + 1, i) + 1

    k += 1

except ValueError:

  print((n-(k or n+1)))

n = int(eval(input()))

k = 0

for x in map(int, input().split()):

  if x == k + 1:

    k += 1

print((n - k if k else -1))

n = int(eval(input()))
a = list(map(int, input().split()))
i = k = 0
try:
    while True:
        i = a.index(k + 1, i) + 1
        k += 1
except ValueError:
    print((n - (k or n + 1)))

n = int(eval(input()))
k = 0
for x in map(int, input().split()):
    if x == k + 1:
        k += 1
print((n - k if k else -1))

-a = list(map(int, input().split())) -i = k = 0 -try: -    while True: -        i = a.index(k + 1, i) + 1 +k = 0 +for x in map(int, input().split()): +    if x == k + 1: -except ValueError: -    print((n - (k or n + 1))) +print((n - k if k else -1))