let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let x = read_line () |> split_string ~pattern:" " |> List.map int_of_string

let rec take res n acc = match (n, acc) with
  | (_, []) | (0, _) -> List.rev res
  | (i, x :: xs) -> take (x :: res) (n - 1) xs
let take = take []

let rec drop n acc = match (n, acc) with
  | (0, acc) -> acc
  | (_, []) -> []
  | (n, x :: xs) -> drop (n - 1) xs

let xs, ys = let acc = List.sort compare x in take (n / 2) acc, drop (n / 2) acc
let a, b = List.rev xs |> List.hd, List.hd ys

let () = x
  |> List.map (fun i -> if i <= a then b else a)
  |> List.iter (Printf.printf "%d\n")