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" @@
  Array.fold_left ( + ) as_.(1) @@
  Array.sub as_ 0 (n - 2)