let N = stdin.ReadLine() |> int

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

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

solver 0 0 |> stdout.WriteLine
