n = int(eval(input()))

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

a.sort()



cnt = a.pop()

tmp = a.pop()

l = 0

for i in range(n - 2):

    if l == 2:

        l = 0

        tmp = a.pop()

    cnt += tmp

    l += 1

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

a = sorted(list(map(int, input().split())))[::-1]

print((a[0] + sum(a[1:n // 2]) * 2 + sum(a[n // 2:n // 2 + n % 2])))
n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
cnt = a.pop()
tmp = a.pop()
l = 0
for i in range(n - 2):
    if l == 2:
        l = 0
        tmp = a.pop()
    cnt += tmp
    l += 1
print(cnt)

n = int(eval(input()))
a = sorted(list(map(int, input().split())))[::-1]
print((a[0] + sum(a[1 : n // 2]) * 2 + sum(a[n // 2 : n // 2 + n % 2])))

-a = list(map(int, input().split())) -a.sort() -cnt = a.pop() -tmp = a.pop() -l = 0 -for i in range(n - 2): -    if l == 2: -        l = 0 -        tmp = a.pop() -    cnt += tmp -    l += 1 -print(cnt) +a = sorted(list(map(int, input().split())))[::-1] +print((a[0] + sum(a[1 : n // 2]) * 2 + sum(a[n // 2 : n // 2 + n % 2])))