n = gets.chomp.to_i
a = []
n.times{a << gets.to_i}
b = a
c = a.sort
max = c[-1]
c.delete(max)
second = c[-1]
for i in 0..(n-1)
    if b[i] != max 
        puts max
    else 
        puts second
    end
end