n = gets.to_i
array = []
for i in 1..n
  array << gets.to_i
end

for i in 0..n-1
  new_array = []
  array.each_with_index do |a, j|
    if i != j
      new_array << a
    end
  end
  puts new_array.max
end