N=input()
N=int(N)
A=[]
for i in range(N):
    b=input()
    b=int(b)
    A.append(b)

max_value=max(A)
for i in range(N):
    if A[i]<max_value:
        print(max_value)
    else:
        data=A.pop(i)
    #    print(lst,i)
        print(max(A))
        A.insert(i,data)
