N=int(input())
Numbers=sorted([int(input()) for i in range(N)])
Amax=Numbers[-1]
Asecond=Numbers[-2]
for j in Numbers:
        if j != Amax:
                print(Amax)
        else:
                print(Asecond)