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