n = int(input())
arr = [int(input()) for _ in range(n)]
arr.sort(reverse=True)
result = 0
for i in range(0, n):
    if (i + 1) % 3 == 0:
        continue
    result += arr[i]
print(result)

b2d835a92ca17c25d71f8e5d6ce4cfeaa3bed99c
<mask token>

<mask token>
arr.sort(reverse=True)
<mask token>
for i in range(0, n):
    if (i + 1) % 3 == 0:
        continue
    result += arr[i]
print(result)

n = int(input())
arr = [int(input()) for _ in range(n)]
arr.sort(reverse=True)
result = 0
for i in range(0, n):
    if (i + 1) % 3 == 0:
        continue
    result += arr[i]
print(result)
