N = int(input())
A = []
m = 0
for i in range(N):
    m = int(input())
    A.append(m)
    #A[i] = int(A[i])
task = 0
m = 0
for i in range(N):
    task = A.pop(i)
    m = max(A)
    print(m)
    A.insert(i,task)