(* 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 ans = ref 0 in
  for i = 1 to n do
    ans := !ans + a_s.(i * 2 - 1)
  done;
  Printf.printf "%d\n" !ans