import sys
input = sys.stdin.readline

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

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))