N = input()
a = []
for i in range(N):
        a.append(input())

b = a.sort()
c = a.reverse()
 
for i in range(N):
        if a[i]!=c[0] :
                print(c[0])
        else:
                print(c[1])
