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