eval(input())

l = sorted(map(int, input().split(' ')))



answer = 0

spots = [l.pop()]

x = len(l)



for i in range(x):

	n = l.pop()

	answer += spots[i]

	spots.append(n)

	spots.append(n)



print(answer)

n = int(eval(input()))

l = list(map(int, input().split(' ')))

l.sort()

s = l.pop()

while n > 3:

	s += l.pop() * 2

	n -= 2

if n == 3:

	s += l.pop()

print(s)
eval(input())
l = sorted(map(int, input().split(" ")))
answer = 0
spots = [l.pop()]
x = len(l)
for i in range(x):
    n = l.pop()
    answer += spots[i]
    spots.append(n)
    spots.append(n)
print(answer)

n = int(eval(input()))
l = list(map(int, input().split(" ")))
l.sort()
s = l.pop()
while n > 3:
    s += l.pop() * 2
    n -= 2
if n == 3:
    s += l.pop()
print(s)

-eval(input()) -l = sorted(map(int, input().split(" "))) -answer = 0 -spots = [l.pop()] -x = len(l) -for i in range(x): -    n = l.pop() -    answer += spots[i] -    spots.append(n) -    spots.append(n) -print(answer) +n = int(eval(input())) +l = list(map(int, input().split(" "))) +l.sort() +s = l.pop() +while n > 3: +    s += l.pop() * 2 +    n -= 2 +if n == 3: +    s += l.pop() +print(s)