n=int(input())
a=[]
for i in range(n):
   a.append(int(input()))
temp=max(a)
for i in range(n):
    if a[i]<temp:
        print(temp)
    else:
        temp2=a.pop(i)
        print(max(a))
        a.insert(i,temp2)