let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d\n" @@ fun a -> a in
  let as' = Array.copy as_ in
  Array.sort (fun a a' -> compare a' a) as';
  Array.iter (fun a ->
    Printf.printf "%d\n" @@ if a = as'.(0) then as'.(1) else as'.(0)) as_

