fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    var a = longList().sorted()
    var total = a.last()
    a = a.dropLast(1)
    var index = a.size - 1
    var d = false
    repeat(n - 2) {
        total += a[index]
        if (d) {
            d = false
            index--
        } else {
            d = true
        }
    }
    println(total.toString())
}