n = gets.chomp.to_i
a=Array.new(n)
for i in 0..n-1
  a[i]=gets.chomp.to_i
end
b=Array.new(n)
b=a.sort{|q,r| r<=>q}
c=Array.new(n)

for i in 0..n-1
  c[i]=b.index(a[i])
end

for i in 0..n-1
  if(c[i]==0)
    puts b[1]
  else
    puts b[0]
  end
end
