func readIntArray() -> [Int] {
    readLine()!.split(separator: " ").map({Int($0)!})
}

let N = Int(readLine()!)!
var A = readIntArray()
A.sort(by: {$0 > $1})

var ans = 0

for i in 1..<N {
    ans += A[i / 2]
}
print(ans)
