Scanf.scanf "%d" (fun n ->
    let a = Array.init (3 * n) (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    Array.sort compare a;

    let rec loop i acc =
        if i = n then acc else loop (i + 1) (acc + a.(n + i))
    in
    loop 0 0 |> Printf.printf "%d\n"
)