open Batteries

let () =
  let n = Scanf.scanf "%d\n" (fun a -> a) in

  let arr = Array.make n 0 in
  for i = 0 to n-1-1 do
    let c = Scanf.scanf "%d " (fun c -> c) in
    Array.set arr i c
  done;
  let c = Scanf.scanf "%d\n" (fun c -> c) in
  Array.set arr (n-1) c;

  let s_arr = Array.copy arr in
  Array.sort compare s_arr;

  let mid1 = Array.get s_arr ((n/2)-1) in
  let mid2 = Array.get s_arr (n/2) in

  for i = 0 to n-1 do
    print_int (
      if ((Array.get arr i) <= mid1) then mid2
      else mid1
    );
    print_endline ""
  done;

