#134
N=int(input())
a=[int(input()) for i in range(N) ]
a_M=[]
a_M.append( max(a[1:]) )
for i in range(1,N):
    if a[i]<a_M[0]:
        a_M.append(a_M[0])
    else:
        s=a[i]
        a[i]=0
        a_M.append( max(a) )
        a[i]=s   
for x in a_M:
    print(x)