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

#最大値とのインデックスを取得する
max_a = max(a)
max_a_index = a.index(max(a))


for i in range(n):
    if i == max_a_index:
        out = max(a[:i],a[i+1:])
        print(*out)
    else:
        print(max_a)