import copy

n = int(input())

columns = [int(input()) for i in range(n)]

i = 0

while i < n:
    if columns[i] == max(columns):
        print(sorted(set(columns))[-1])
    else:
        print(max(columns))
    i += 1