import sys

sys.setrecursionlimit(1 << 25)

read = sys.stdin.readline

ra = range

enu = enumerate





def exit(*argv, **kwarg):

    print(*argv, **kwarg)

    sys.exit()





def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))

# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと





def a_int(): return int(read())





def ints(): return list(map(int, read().split()))





def read_col(H):

    '''H is number of rows

    A列、B列が与えられるようなとき

    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''

    ret = []

    for _ in range(H):

        ret.append(list(map(int, read().split())))

    return tuple(map(list, zip(*ret)))





def read_tuple(H):

    '''H is number of rows'''

    ret = []

    for _ in range(H):

        ret.append(tuple(map(int, read().split())))

    return ret





def read_matrix(H):

    '''H is number of rows'''

    ret = []

    for _ in range(H):

        ret.append(list(map(int, read().split())))

    return ret

    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため





MOD = 10**9 + 7

INF = 2**31  # 2147483648 > 10**9

# default import

from collections import defaultdict, Counter, deque

from operator import itemgetter, xor, add

from itertools import product, permutations, combinations

from bisect import bisect_left, bisect_right  # , insort_left, insort_right

from functools import reduce

from math import gcd





def lcm(a, b):

    # 最小公倍数

    g = gcd(a, b)

    return a // g * b



# 貪欲に大きい方だと思うんだけど違うのかな

# 貪欲でない反例 (わからん)





N = a_int()

A = ints()

A.sort()

ans = A.pop()

N -= 2

while N > 1:

    N -= 2

    ans += 2 * A.pop()

if N == 1:

    ans += A.pop()

print(ans)

import sys

sys.setrecursionlimit(1 << 25)

read = sys.stdin.readline

ra = range

enu = enumerate





def exit(*argv, **kwarg):

    print(*argv, **kwarg)

    sys.exit()





def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))

# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと





def a_int(): return int(read())





def ints(): return list(map(int, read().split()))





def read_col(H):

    '''H is number of rows

    A列、B列が与えられるようなとき

    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''

    ret = []

    for _ in range(H):

        ret.append(list(map(int, read().split())))

    return tuple(map(list, zip(*ret)))





def read_tuple(H):

    '''H is number of rows'''

    ret = []

    for _ in range(H):

        ret.append(tuple(map(int, read().split())))

    return ret





def read_matrix(H):

    '''H is number of rows'''

    ret = []

    for _ in range(H):

        ret.append(list(map(int, read().split())))

    return ret

    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため





MOD = 10**9 + 7

INF = 2**31  # 2147483648 > 10**9

# default import

from collections import defaultdict, Counter, deque

from operator import itemgetter, xor, add

from itertools import product, permutations, combinations

from bisect import bisect_left, bisect_right  # , insort_left, insort_right

from functools import reduce

from math import gcd





def lcm(a, b):

    # 最小公倍数

    g = gcd(a, b)

    return a // g * b



# https://atcoder.jp/contests/abc173/tasks/abc173_d

# 大きい方から使いそう





N = a_int()

A = ints()

A.sort(reverse=True)

ans = A[0]

cnt = 1

for a in A[1:]:

    if cnt == N - 1:

        break

    ans += a

    cnt += 1

    if cnt == N - 1:

        break

    ans += a

    cnt += 1



print(ans)

import sys

sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1):
    return list(map(lambda x: x - sub, argv))


# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと
def a_int():
    return int(read())


def ints():
    return list(map(int, read().split()))


def read_col(H):
    """H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合"""
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    """H is number of rows"""
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    """H is number of rows"""
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


# 貪欲に大きい方だと思うんだけど違うのかな
# 貪欲でない反例 (わからん)
N = a_int()
A = ints()
A.sort()
ans = A.pop()
N -= 2
while N > 1:
    N -= 2
    ans += 2 * A.pop()
if N == 1:
    ans += A.pop()
print(ans)

import sys

sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1):
    return list(map(lambda x: x - sub, argv))


# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと
def a_int():
    return int(read())


def ints():
    return list(map(int, read().split()))


def read_col(H):
    """H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合"""
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    """H is number of rows"""
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    """H is number of rows"""
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


# https://atcoder.jp/contests/abc173/tasks/abc173_d
# 大きい方から使いそう
N = a_int()
A = ints()
A.sort(reverse=True)
ans = A[0]
cnt = 1
for a in A[1:]:
    if cnt == N - 1:
        break
    ans += a
    cnt += 1
    if cnt == N - 1:
        break
    ans += a
    cnt += 1
print(ans)

-# 貪欲に大きい方だと思うんだけど違うのかな -# 貪欲でない反例 (わからん) +# https://atcoder.jp/contests/abc173/tasks/abc173_d +# 大きい方から使いそう -A.sort() -ans = A.pop() -N -= 2 -while N > 1: -    N -= 2 -    ans += 2 * A.pop() -if N == 1: -    ans += A.pop() +A.sort(reverse=True) +ans = A[0] +cnt = 1 +for a in A[1:]: +    if cnt == N - 1: +        break +    ans += a +    cnt += 1 +    if cnt == N - 1: +        break +    ans += a +    cnt += 1