n = gets.chomp.to_i

progression = []
n.times { |_i| progression << gets.chomp.to_i}

sorting_progression = progression.sort

n.times do |i|
  remove_number = progression[i]
  if sorting_progression[-1] == remove_number
    puts sorting_progression[-2]
    next
  end
  
  puts sorting_progression[-1]
end
