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)
    sorted.zipWithIndex.foldLeft(0) { case (acc, (num, i)) =>
      if(i != 0 && i >= Math.ceil(n.toDouble / 2)) acc + sorted(i-1) + num
      else acc
    }
  }


  println(solve())

}

