function main()
  
  N = parse(Int,readline())
  A = zeros(Int,N)
  
  for i in 1:N
    A[i] = parse(Int,readline())
  end
  
  for i in 1:N
    println(max(A[1:i-1]...,A[i+1:end]...))
  end

end
  
main()