n = int(eval(input()))

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

list_a_complete = []

k = 1

ans = -2



for i in range(n):

    if list_a[i] == k:

        list_a_complete.append(k)

        k += 1



if len(list_a_complete) == 0:

    ans = -1



else:

    ans = len(list_a) - len(list_a_complete)



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

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

cnt = 1

for i in range(n):

    if list_score[i] == cnt:

        cnt += 1

ans = 0

cnt -= 1

if cnt == 0:

    ans = -1

else:

    ans = len(list_score) - cnt

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

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

-list_a = list(map(int, input().split())) -list_a_complete = [] -k = 1 -ans = -2 +list_score = list(map(int, input().split())) +cnt = 1 -    if list_a[i] == k: -        list_a_complete.append(k) -        k += 1 -if len(list_a_complete) == 0: +    if list_score[i] == cnt: +        cnt += 1 +ans = 0 +cnt -= 1 +if cnt == 0: -    ans = len(list_a) - len(list_a_complete) +    ans = len(list_score) - cnt