N=int(input())
l=list()
for i in range(N):
    l.append(int(input()))

num=list()
M=max(l)
for k in range(N):
    if(k[i]==M):
        num=l[:k]+l[k+1:]
        print(max(num))
    else:
        print(M)
