n=int(eval(input()))

a=sorted(list(map(int,input().split())),reverse=True)

ans=0

for i in range(n-1):

    ans+=a[(i+1)//2]

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

a=sorted(list(map(int,input().split())),reverse=1)

b=0

for i in range(n-1):

    b+=a[(i+1)//2]

print(b)
n = int(eval(input()))
a = sorted(list(map(int, input().split())), reverse=True)
ans = 0
for i in range(n - 1):
    ans += a[(i + 1) // 2]
print(ans)

n = int(eval(input()))
a = sorted(list(map(int, input().split())), reverse=1)
b = 0
for i in range(n - 1):
    b += a[(i + 1) // 2]
print(b)

-a = sorted(list(map(int, input().split())), reverse=True) -ans = 0 +a = sorted(list(map(int, input().split())), reverse=1) +b = 0 -    ans += a[(i + 1) // 2] -print(ans) +    b += a[(i + 1) // 2] +print(b)