N = int(eval(input()))

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

src.sort()

ans = 0

for a,b in zip(src[::2],src[1::2]):

    ans += a

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

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

L.sort(reverse=True)



ans = 0

for a,b in zip(L[::2],L[1::2]):

    ans += min(a,b)

print(ans)
N = int(eval(input()))
src = list(map(int, input().split()))
src.sort()
ans = 0
for a, b in zip(src[::2], src[1::2]):
    ans += a
print(ans)

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort(reverse=True)
ans = 0
for a, b in zip(L[::2], L[1::2]):
    ans += min(a, b)
print(ans)

-src = list(map(int, input().split())) -src.sort() +L = list(map(int, input().split())) +L.sort(reverse=True) -for a, b in zip(src[::2], src[1::2]): -    ans += a +for a, b in zip(L[::2], L[1::2]): +    ans += min(a, b)