@staticmethod
def d():
    (n, *a) = map(int, sys.stdin.read().split())
    a.sort(reverse=True)
    res = ((a[0] + (sum(a[1:(1 + ((n - 2) // 2))]) * 2)) + (a[(1 + ((n - 2) // 2))] * (n & 1)))
    print(res)
@staticmethod
def d():
    (n, *a) = map(int, sys.stdin.read().split())
    a.sort(reverse=True)
    res = ((a[0] + (sum(a[1:(1 + ((n - 2) // 2))]) * 2)) + (a[(1 + ((n - 2) // 2))] * (n & 1)))
    print(res)