Scanf.scanf "%d" (fun n ->
    let x = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
    let y = Array.copy x in
    Array.sort compare y;

    let mi = y.(n / 2) in
    let mx = y.(n / 2 - 1) in

    Array.iter (fun i -> Printf.printf "%d\n" @@ if i <= mx then mi else mx) x
)