N = int(input())
D = [0 for i in range(0,N)]
for i in range(0,N):
    D[i] = int(input())

for i in range(N):
    d = D[i]
    if d < max(D):
        print(max(D))
    else:
        l = D.copy()
        l.pop(i)
        print(max(l))