n = int(input())
a = [int(input()) for _ in range(n)]
max_a = max(a)
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)

