object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val n    = inputs.head.toInt
  val nums = inputs(1).split(" ").map(_.toInt)

  println(solve(n, nums))

  def solve(n: Int, nums: Seq[Int]): Long = {
    var comfort = 0L
    var currentMinNum  = 0
    val sortedNums = nums.sorted

    Range.inclusive(n - 1, 0, -1).foreach { i =>
      comfort = comfort + currentMinNum
      currentMinNum = sortedNums(i)
    }
    comfort
  }
}