let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let arr = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let () = Array.fast_sort (fun x y -> y-x) arr in
  let ans = ref 0 in
  for i = 0 to n - 2 do
    if i mod 2 = 0 then ans := !ans + arr.(i/2)
    else ans := !ans + arr.(i/2+1)
  done;
  Printf.printf "%d\n" !ans