(* 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 f (i, acc) a = i + 1, acc + if i <= 2 * n && i mod 2 = 0 then a else 0 in
  Array.fold_left f (1, 0) a_s |> snd |> Printf.printf "%d\n"