let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  Array.sort (Fun.flip compare) as_;
  Printf.printf "%d\n" @@
  ( + ) (as_.(0) + if n mod 2 = 1 then as_.((n - 1) / 2) else 0) @@
  ( * ) 2 @@
  Array.fold_left ( + ) 0 @@
  Array.sub as_ 1 ((n - 2) / 2)