import copy as cp
N = int(input())
numbers = [int(input()) for i in range(N)]

max_num = max(numbers)

for i in range(len(numbers)):
    if numbers[i] == max_num:
        temp_numbers = cp.copy(numbers)
        temp_numbers.pop(i)
        print(max(temp_numbers))
    else :
        print(max_num)