n = int(input())
nums = [None] * n

for i in range(n):
    nums[i] = int(input())
sorted_nums = sorted(nums)

for i in range(n):
    if sorted_nums.index(nums[i]) == n - 1:
        max_val = sorted_nums[n - 2]
    else:
        max_val = sorted_nums[n - 1]
    print(max_val)
