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

[|2..N-1|]
|> Array.sumBy (fun x -> int64(A.[N-1-x/2]))
|> fun x -> x+int64(A.[N-1])
|> stdout.WriteLine