import copy

n = int(input())
a_lst = []
for i in range(n):
    a = int(input())
    a_lst.append(a)

max_a = max(a_lst)

for a in a_lst:
    if a == max_a:
        tmp = copy.copy(a_lst)
        tmp.remove(a)
        print(max(tmp))
    else:
        print(max_a)