N = input()
a = []
for i in range(N):
        a.append(input())
B = max(a)
for i in range(N):
        if B == max(a):
                b = a.pop(i)
                print(max(a))
                a.insert(i,b)
        else:
                print(B)