gets.to_i
array = readlines.map(&:chomp).map(&:to_i)
max_number = array.max
ary = array.clone
ary.delete(max_number)
secand_max = ary.max
if secand_max
    array.size.times do |order|
        if  array[order] == max_number
            p secand_max
        else
            p max_number
        end
    end
else
    array.size.times do
        p max_number
    end
end
