class Array
  def remove_at(pos)
    temp = self.dup
    temp.delete_at(pos)
    temp
  end
end

n = gets.to_i
i = 0
arr = Array.new(n, 0)
arr.map!{|i|i = gets.to_i}
j = 0
while j < n
  puts arr.remove_at(j).max
  j += 1
end
