N =int(input())
nums = [int(input()) for i in range(N)]
m1 = sorted(set(nums))[-1]
for i in range(N):
  if nums[i] == m1:
    if len(set(nums)) == 1 :
      print(m1)
    else:
      m2 = sorted(set(nums))[-2]
      print(m2)      
  else:
    print(m1)