import copy
n = int(input())
a = [int(input()) for i in range(n)]
a_max = max(a)
for i in range(n):
    if a_max == a[i]:
        a_ = copy.deepcopy(a)
        del a_[i]
        print(max(a_))
    else:
        print(a_max)
