let rec tabulate n f = 
  let rec loop acc m =
    if m < n then loop (f m :: acc) (m + 1)
    else List.rev acc in
  loop [] 0

let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let ls = tabulate (2 * n) (fun _ -> Scanf.scanf "%d " (fun l -> l)) in
  List.sort compare ls
  |> List.fold_left (fun (prev, acc) l ->
      match prev with
      | None -> (Some l, acc)
      | Some l' -> (None, (l, l') :: acc)) (None, [])
  |> snd
  |> List.map (fun (l, l') -> min l l')
  |> List.fold_left ( + ) 0
  |> Printf.printf "%d\n"
