N = input()
a = []
for i in range(N):
        a.append(input())
B = max(a)
for i in range(N):
        if a[i]!=B :
                print(B)
        else:
                a.sort()
                print(a[-2])
