import sys

read = sys.stdin.read

def main():

    n, *a = list(map(int, read().split()))

    a.sort(reverse=True)

    r = a[0]

    end = int((n - 2) // 2)

    r += sum(a[1:end+1]) * 2

    if n % 2 == 1:

        r += a[end+1]

    print(r)



if __name__ == '__main__':

    main()

import sys

read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

from collections import deque

def main():

    n, *a = list(map(int, read().split()))

    a.sort(reverse=True)

    a = deque(a)

    circle_joined = deque()

    next_score = a.popleft()

    r = 0

    flag = False

    while a:

        circle_joined.append(a.popleft())

        if flag:

            next_score = circle_joined.popleft()

            r += next_score

            flag = False

        else:

            r += next_score

            flag = True

    print(r)



if __name__ == '__main__':

    main()

import sys

read = sys.stdin.read


def main():
    n, *a = list(map(int, read().split()))
    a.sort(reverse=True)
    r = a[0]
    end = int((n - 2) // 2)
    r += sum(a[1 : end + 1]) * 2
    if n % 2 == 1:
        r += a[end + 1]
    print(r)


if __name__ == "__main__":
    main()

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from collections import deque


def main():
    n, *a = list(map(int, read().split()))
    a.sort(reverse=True)
    a = deque(a)
    circle_joined = deque()
    next_score = a.popleft()
    r = 0
    flag = False
    while a:
        circle_joined.append(a.popleft())
        if flag:
            next_score = circle_joined.popleft()
            r += next_score
            flag = False
        else:
            r += next_score
            flag = True
    print(r)


if __name__ == "__main__":
    main()

+readline = sys.stdin.readline +readlines = sys.stdin.readlines +from collections import deque -    r = a[0] -    end = int((n - 2) // 2) -    r += sum(a[1 : end + 1]) * 2 -    if n % 2 == 1: -        r += a[end + 1] +    a = deque(a) +    circle_joined = deque() +    next_score = a.popleft() +    r = 0 +    flag = False +    while a: +        circle_joined.append(a.popleft()) +        if flag: +            next_score = circle_joined.popleft() +            r += next_score +            flag = False +        else: +            r += next_score +            flag = True