#https://atcoder.jp/contests/abc134/tasks/abc134_c

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

for i in range(n):
    b = max(a)
    if b == a[i]:
        c = sorted(a,reverse = True)
        b = c[1]
    print(b)