N = int(eval(input()))

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

A.sort()

if N==2:

    print((max(A)))

    exit()



ans = A.pop()

n = N-2

while A:

    a = A.pop()

    for _ in range(2):

        n -= 1

        ans += a

        if n==0:

            print(ans)

            exit()
N = int(eval(input()))

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

A.sort(reverse=True)



ans = 0

for i in range(1,N):

    ans += A[i//2]

print(ans)
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
if N == 2:
    print((max(A)))
    exit()
ans = A.pop()
n = N - 2
while A:
    a = A.pop()
    for _ in range(2):
        n -= 1
        ans += a
        if n == 0:
            print(ans)
            exit()

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

-A.sort() -if N == 2: -    print((max(A))) -    exit() -ans = A.pop() -n = N - 2 -while A: -    a = A.pop() -    for _ in range(2): -        n -= 1 -        ans += a -        if n == 0: -            print(ans) -            exit() +A.sort(reverse=True) +ans = 0 +for i in range(1, N): +    ans += A[i // 2] +print(ans)