let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  let a' = Array.init n (fun i -> a.(i)) in
  Array.sort (-) a';
  let m1, m2 = a'.(n/2-1), a'.(n/2) in
  Array.iter (fun e ->
    Printf.printf "%d\n" @@ if e <= m1 then m2 else m1) a