import java.util.*
import kotlin.collections.ArrayList

fun main(){
    val n = rInt()
    val a = readLine()!!.split(' ').map { it.toLong() } as ArrayList<Long>
//    val a = arrayListOf<Long>()
//    for (i in 1..n) a.add(rLong())

    a.sortDescending()

    var ans = a[0]

    for (i in 2 until n){
        ans += a[i/2]
    }

    println(ans)


}



// input
private val inputQue = ArrayList<String>()
private fun myReadLine(){
    inputQue.addAll(readLine()!!.split(' '))
}
private fun read() : String {
    if(inputQue.isEmpty()) myReadLine()
    return inputQue.removeAt(0)
}
private fun rInt() = read().toInt()
private fun rLong() = read().toLong()
private fun rDouble() = read().toDouble()
