N = int(eval(input()))

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



A.sort(reverse=True)

cnt = 1

idx = 0

ans = 0

while cnt <= N-1:

    ans += A[idx]

    if cnt % 2 == 1:

        #ans += A[idx]

        idx += 1

    #else:

        #ans += A[idx]

    cnt += 1

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

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

A.sort(reverse=True)

ans = A[0] #最大値だけ1回

for i in range(N-2):

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

print(ans)
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort(reverse=True)
cnt = 1
idx = 0
ans = 0
while cnt <= N - 1:
    ans += A[idx]
    if cnt % 2 == 1:
        # ans += A[idx]
        idx += 1
    # else:
    # ans += A[idx]
    cnt += 1
print(ans)

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

-cnt = 1 -idx = 0 -ans = 0 -while cnt <= N - 1: -    ans += A[idx] -    if cnt % 2 == 1: -        # ans += A[idx] -        idx += 1 -    # else: -    # ans += A[idx] -    cnt += 1 +ans = A[0]  # 最大値だけ1回 +for i in range(N - 2): +    ans += A[i // 2 + 1]