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

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