import java.util.Scanner

import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val A = readLine().split(" ").map(_.toInt)

  def solve() = {
    val sorted = A.sorted(Ordering[Int].reverse)
    (1 until n).foldLeft(0L) { (acc, i) => 
      acc + sorted(i/2) 
    }
  }


  println(solve())

}

