N = int(input())
 
A = []

for i in range(N):
    A.append(int(input()))

for i in range(N):
    k = max(A)
    if k != A[i]:
        print(k)
    else:
        j = A.pop(i)
        print(k)
        A.insert(i,j)