N = int(eval(input()))

l = [int(x) for x in input().split(" ")]



import numpy as np

ans=0

while len(l) !=0:

    x=0

    y=0

    x+=max(l)

    l.pop(np.argmax(l))

    y+=max(l)

    l.pop(np.argmax(l))

    ans+=min(x,y)

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

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

L.sort()

ans = 0

while len(L) != 0:

    ans += min(L.pop(0), L.pop(0))

print(ans)
N = int(eval(input()))
l = [int(x) for x in input().split(" ")]
import numpy as np

ans = 0
while len(l) != 0:
    x = 0
    y = 0
    x += max(l)
    l.pop(np.argmax(l))
    y += max(l)
    l.pop(np.argmax(l))
    ans += min(x, y)
print(ans)

N = int(eval(input()))
L = [int(i) for i in input().split()]
L.sort()
ans = 0
while len(L) != 0:
    ans += min(L.pop(0), L.pop(0))
print(ans)

-l = [int(x) for x in input().split(" ")] -import numpy as np - +L = [int(i) for i in input().split()] +L.sort() -while len(l) != 0: -    x = 0 -    y = 0 -    x += max(l) -    l.pop(np.argmax(l)) -    y += max(l) -    l.pop(np.argmax(l)) -    ans += min(x, y) +while len(L) != 0: +    ans += min(L.pop(0), L.pop(0))