n = int(input())
a = [0] * n
#dp = []

for i in range(n):
    a[i] = int(input())

maxV = max(a)

for i in range(n):
    if a[i] == maxV:
        new = list(a)
        del new[i]
        print(max(new))
    else:
        print(maxV)
