N = int(eval(input()))

A_list = [int(n) for n in input().split()]

A_list.sort(reverse = True)

ans = 0



for i in range(1,N):

    ans += A_list[i // 2]



print(ans)

N=int(eval(input()))

A=[int(i) for i in input().split()]



A.sort(reverse=True)





if N%2==1:

    if N==3:

        ans=A[0]+A[1]

    else:

        ans=A[0]

        for i in range(1,N//2):

            ans+=A[i]*2

        ans+=A[N//2]

else:

    ans=A[0]

    for i in range(1,N//2):

        ans+=A[i]*2



print(ans)

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

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

-A_list = [int(n) for n in input().split()] -A_list.sort(reverse=True) -ans = 0 -for i in range(1, N): -    ans += A_list[i // 2] +A = [int(i) for i in input().split()] +A.sort(reverse=True) +if N % 2 == 1: +    if N == 3: +        ans = A[0] + A[1] +    else: +        ans = A[0] +        for i in range(1, N // 2): +            ans += A[i] * 2 +        ans += A[N // 2] +else: +    ans = A[0] +    for i in range(1, N // 2): +        ans += A[i] * 2