n = int(input())
num_list = []
for _ in range(n):
    num_list.append(int(input()))

copy = num_list.copy()
copy.sort()
maximum = copy[-1]

for i in range(n):
    if num_list[i] == maximum:
        tmp = num_list[:i]+num_list[i+1:]
        tmp.sort()
        print(tmp[-1])
    else:
        print(maximum)