//
//  main.swift
//  TestSpace for AtCoder
//
//  Created by Koichi Okai on 2020/06/25.
//  Copyright © 2020 Koichi Okai. All rights reserved.
//

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

func main() {
    let N = Int(readLine()!)!
    
    let a = readInts().sorted()
    
    let val = (1..<N).map { a[N-1 - $0/2] }.reduce(0) { $0 + $1 }

    print(val)
}

main()
