import copy
n = int(input())
all_list = [int(input()) for _ in range(n)]
max_value = max(all_list)
for i in range(n):
    if all_list[i] == max_value:
        tmp = copy.copy(all_list)
        tmp.pop(i)
        print(max(tmp))
    else:
        print(max_value)