let N = Int(readLine()!)!
var As: [Int] = readLine()!.split(separator: " ").map { Int($0)! }
As.sort(by: >)

var res: Int = As[0]

for i in 0 ..< N - 2 {
    res += As[1 + i / 2]
}
print(res)  // (๑•ૅㅁ•๑)