import sys

input = sys.stdin.readline



n = int(eval(input()))

nums = [None] * n



for i in range(n):

    nums[i] = int(eval(input()))

sorted_nums = sorted(nums)



for i in range(n):

    max_val = sorted_nums[n - 1]

    if nums[i] == max_val:

        max_val = sorted_nums[n - 2]

    print(max_val)

import sys

input = sys.stdin.readline



n = int(eval(input()))

nums = [None] * n



for i in range(n):

    nums[i] = int(eval(input()))

sorted_nums = sorted(nums)



for num in nums:

    max_val = sorted_nums[n - 1]

    if num == max_val:

        max_val = sorted_nums[n - 2]

    print(max_val)

import sys

input = sys.stdin.readline
n = int(eval(input()))
nums = [None] * n
for i in range(n):
    nums[i] = int(eval(input()))
sorted_nums = sorted(nums)
for i in range(n):
    max_val = sorted_nums[n - 1]
    if nums[i] == max_val:
        max_val = sorted_nums[n - 2]
    print(max_val)

import sys

input = sys.stdin.readline
n = int(eval(input()))
nums = [None] * n
for i in range(n):
    nums[i] = int(eval(input()))
sorted_nums = sorted(nums)
for num in nums:
    max_val = sorted_nums[n - 1]
    if num == max_val:
        max_val = sorted_nums[n - 2]
    print(max_val)

-for i in range(n): +for num in nums: -    if nums[i] == max_val: +    if num == max_val: