n = int(input())
a = [ int(input()) for x in range(n) ] 

maximum = max(a)

for i in a:
    if i == maximum:
        b = a.copy()
        b.remove(i)
        print( max(b) )
    else:
        print(maximum)