N, *d = map(int, open(0).read().split())
m=d.index(max(d))
for i in range(N-1):
    if(i==m):
        temp=d[i]
        d[i]=0
        y=max(d)
        print(y)
        d[i]=temp
    
    print(max(d))