let () =
    let _ = read_int () in
    let x =
        read_line ()
        |> Str.split (Str.regexp " ")
        |> List.map int_of_string
    in
    let length = List.length x in
    let sorted_x = List.sort compare x in
    let lesser_median = List.nth sorted_x (length / 2 - 1) in
    let greater_median = List.nth sorted_x (length / 2) in
    List.map (fun n -> if n > lesser_median then lesser_median else greater_median) x
    |> List.iter (fun n -> print_endline (string_of_int n))
