n = int(input())
m = 0
a = []
for _ in range(n):
    _a = int(input())
    m = max(m, _a)
    a.append(_a)

for i in range(n):
    if a[i] == m:
        t = a[:]
        t.pop(i)
        print(max(t))
    else:
        print(m)
