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

a.each_with_index do |item, i|
  l_arr = i==0 ? [1] : a.slice(0..(i-1))
  r_arr = i==n-1 ? [1] : a.slice((i+1)..(n-1))
  res << [l_arr.max, r_arr.max].max
end

puts res
