n = gets.to_i
a = readlines.map {|i| i.chomp.to_i}

a.each_with_index do |item, i|
  l_arr = i==0 ? [] : a.slice(0..(i-1))
  r_arr = i==n-1 ? [] : a.slice((i+1)..(n-1))
  max = [l_arr, r_arr].flatten.max
  puts "#{max}\n"
end