n= int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())
b = a
max1 = max(a)

for i in range(n):
    if a[i] == max1:
        a[i] = 0
        max2 = max(a)
        print(max2)
        a[i] = max1
        
    else:
        print(max1)