object Main extends App {
  import scala.annotation.tailrec
  
  @tailrec
  def solve(a:Array[Long],ans:Long):Long = {
    if (a.length == 3) ans+a(1)
    else solve(a.take(a.length-2).tail,ans+a(a.length-2))
  }
 
  val n = readLong
  val a = readLine.split(" ").map{_.toLong}.sorted.toArray
  println(solve(a,0))
}