import kotlin.math.ceil

fun main() = Thread(null, ::abc173d, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc173d() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toLong() }

    if (n == 2) return println(aList.max()!!)

    val half = ceil(n.toDouble() / 2).toInt()
    val remHalf = n - half

    val sortedHalf = aList.sortedDescending().take(half)

    val answer = sortedHalf.dropLast(1).sum() +
            sortedHalf.drop(1).take(remHalf - 1).sum() + sortedHalf.last()

    println(answer)
}
