let N = stdin.ReadLine() |> int64

let A =
    stdin.ReadLine().Split()
    |> Array.sortDescending
    |> Array.map int64

let rec solver s i =
    if i = N - 1L then s
    else solver (s + A.[int ((i + 1L) / 2L)]) (i + 1L)

solver 0L 0L |> stdout.WriteLine
