from collections import Counter,defaultdict,deque

import sys,bisect,math,itertools,string,queue

from heapq import heappop, heappush

sys.setrecursionlimit(10**8)

mod = 10**9+7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))



n = inp()

a = inpl()

a.sort()

res = 0

ind = n

for i in range(n):

    if i == 0:

        res += a[ind]

        continue

    ind += 2

    res += a[ind]

print(res)
from collections import Counter,defaultdict,deque

from heapq import heappop,heappush,heapify

import sys,bisect,math,itertools,fractions,pprint

sys.setrecursionlimit(10**8)

mod = 10**9+7

INF = float('inf')

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))



n = inp()

a = inpl()

a.sort(reverse = True)

cnt = n

ind = 0

res = 0

while cnt:

    if ind % 2:

        res += a[ind]

        cnt -= 1

    ind += 1

print(res)
from collections import Counter, defaultdict, deque
import sys, bisect, math, itertools, string, queue
from heapq import heappop, heappush

sys.setrecursionlimit(10**8)
mod = 10**9 + 7


def inp():
    return int(sys.stdin.readline())


def inpl():
    return list(map(int, sys.stdin.readline().split()))


def inpl_str():
    return list(sys.stdin.readline().split())


def inpln(n):
    return list(int(sys.stdin.readline()) for i in range(n))


n = inp()
a = inpl()
a.sort()
res = 0
ind = n
for i in range(n):
    if i == 0:
        res += a[ind]
        continue
    ind += 2
    res += a[ind]
print(res)

from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions, pprint

sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")


def inp():
    return int(sys.stdin.readline())


def inpl():
    return list(map(int, sys.stdin.readline().split()))


n = inp()
a = inpl()
a.sort(reverse=True)
cnt = n
ind = 0
res = 0
while cnt:
    if ind % 2:
        res += a[ind]
        cnt -= 1
    ind += 1
print(res)

-import sys, bisect, math, itertools, string, queue -from heapq import heappop, heappush +from heapq import heappop, heappush, heapify +import sys, bisect, math, itertools, fractions, pprint +INF = float("inf") -def inpl_str(): -    return list(sys.stdin.readline().split()) - - -def inpln(n): -    return list(int(sys.stdin.readline()) for i in range(n)) - - -a.sort() +a.sort(reverse=True) +cnt = n +ind = 0 -ind = n -for i in range(n): -    if i == 0: +while cnt: +    if ind % 2: -        continue -    ind += 2 -    res += a[ind] +        cnt -= 1 +    ind += 1