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

max_val = max(a)

for i in range(n):
    if max_val > a[i]:
        print(max_val)
        
    elif max_val == a[i]:
        temp = a[i]
        a[i] = 0
        print(max(a))
        a[i] = temp