l=[]
q=[]
t=int(input())
for i in range(t):
    l.append(int(input()))
    if(l[i] not in q):
        q.append(l[i])
q.sort()
y=len(q)
for i in range(0,t):
    if(l[i]!=q[y-1]):
        print(q[y-1])
    else:
        print(q[y-2])
