import copy

n = int(input())

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

i = 0

while i < n:
    max_value = sorted(set(columns))[-1]
    if max_value == columns[i]:
        tmp = copy.copy(columns)
        del tmp[i]
        print(sorted(set(tmp))[-1])
    else:
        print(max_value)
    i += 1