(* O(n log n) *)
Scanf.scanf "%d" @@ fun n ->
  let a_s = Array.init (3 * n) @@ fun _ -> Scanf.scanf " %d" @@ (+) 0 in
  Array.sort (fun x y -> y - x) a_s;
  let a2s = Array.init n @@ fun i -> a_s.(i * 2 + 1) in
  Array.fold_left (+) 0 a2s |> Printf.printf "%d\n"