N = int(input())
nums = []
for i in range(N):
    nums.append(int(input()))

maxinum = max(nums)
for i in range(N):
    if nums[i] == maxinum:
        print(max(nums[0:i] + nums[i+1:]))
    else:
        print(maxinum)