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