n = int(input())
a = [int(input()) for i in range(n)]
maxnum = max(a)
for i in range(n):
    if a[i] == maxnum:
        tmp = a[i]
        a[i] = 0
        print(max(a))
        a[i] = tmp
    else:
        print(max(a))