import sys



readline = sys.stdin.readline

readall = sys.stdin.read

ns = lambda: readline().rstrip()

ni = lambda: int(readline().rstrip())

nm = lambda: map(int, readline().split())

nl = lambda: list(map(int, readline().split()))

prn = lambda x: print(*x, sep='\n')



def solve():

    n = ni()

    a = sorted(nl(), reverse=True)

    c = a[0]

    n -= 2

    for x in a[1:]:

        if n == 0:

            break

        if n == 1:

            c += x

            n -= 1

        else:

            c += x * 2

            n -= 2

    print(c)

    return



solve()

import sys



readline = sys.stdin.readline

readall = sys.stdin.read

ns = lambda: readline().rstrip()

ni = lambda: int(readline().rstrip())

nm = lambda: map(int, readline().split())

nl = lambda: list(map(int, readline().split()))

prn = lambda x: print(*x, sep='\n')



def solve():

    n = ni()

    a = sorted(nl(), reverse=True)

    print(sum(a[:n//2]) + sum(a[1:(n+1)//2]))

    return



solve()

import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep="\n")


def solve():
    n = ni()
    a = sorted(nl(), reverse=True)
    c = a[0]
    n -= 2
    for x in a[1:]:
        if n == 0:
            break
        if n == 1:
            c += x
            n -= 1
        else:
            c += x * 2
            n -= 2
    print(c)
    return


solve()

import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep="\n")


def solve():
    n = ni()
    a = sorted(nl(), reverse=True)
    print(sum(a[: n // 2]) + sum(a[1 : (n + 1) // 2]))
    return


solve()

-    c = a[0] -    n -= 2 -    for x in a[1:]: -        if n == 0: -            break -        if n == 1: -            c += x -            n -= 1 -        else: -            c += x * 2 -            n -= 2 -    print(c) +    print(sum(a[: n // 2]) + sum(a[1 : (n + 1) // 2]))