n = int(input())
nums = []
for i in range(n):
  nums.append(int(input()))
cache = sorted(nums)
maximum = nums[0]
second = nums[1]
for i in nums:
  if i == maximum:
    print(second)
  else:
    print(maximum)
