inp = int(input())
A = []
for a in range(inp):
    A.append(int(input()))
    
m = max(A)

for i, a in enumerate(A):
    if a == m:
        A2 = [v for i2, v in enumerate(A) if i2 != i]
        print(max(A2))
    else:
        print(m)
