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

n = gets.to_i
i = 0
arr = []
while i < n
  arr << gets.to_i
  i += 1
end
j = 0
while j < n
  puts arr.remove_at(j).max
  j += 1
end
