N = int(eval(input()))

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

A.sort()

A = A[::-1]

ans = A[0]

for i in range(N-2):

  ans += A[1 + i//2]

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

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



A.sort(reverse=True)

ans = 0

for i in range(N-1):

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



print(ans)
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
A = A[::-1]
ans = A[0]
for i in range(N - 2):
    ans += A[1 + i // 2]
print(ans)

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

-A.sort() -A = A[::-1] -ans = A[0] -for i in range(N - 2): -    ans += A[1 + i // 2] +A.sort(reverse=True) +ans = 0 +for i in range(N - 1): +    ans += A[(i + 1) // 2]