N = int(input())
A = [int(input()) for i in range(N)]
max = [0]*N

for i in range(N):
    for j in range(N):
        if i != j:    
            if max[i] < A[j]:
                max[i] = A[j]

for i in range(N):
    print(max[i])