n = int(input())
a = [int(input()) for _ in range(n)]
max_a = max(a)
tmp_a = a.copy()
count = 0
for i in range(n):
    if tmp_a[i] == max_a:
        count += 1

if count == 1:
    for i in range(len(a)):
        tmp_a = a.copy()
        if tmp_a[i] == max_a:
            del tmp_a[i]
            print(max(tmp_a))
        else:
            print(max_a)
else:
    for i in range(len(a)):
        print(max_a)

