open System.Linq
let read conv = stdin.ReadLine() |> conv
let reads n =
    let mutable acc = System.Collections.Generic.List<int>()
    for i = 1 to n do
        acc.Add (stdin.ReadLine() |> int)
    acc

let n = read int
let ls = reads n
let ms = ls.OrderBy(fun x -> x).ToList()
for i = 0 to (n-1) do
    printfn "%d" (if ls.[i] = ms.[n-1] then ms.[n-2] else ms.[n-1])
