n = int(input())
value_list = []

for i in range(n):
    value_list.append(int(input()))

most_max = max(value_list)

for i in range(n):
    if value_list[i] == most_max:
        value_list[i] = 0
        print(max(value_list))
        value_list[i] = most_max
    else:
        print(most_max)