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


for i in range(N):
    mx = 0
    if A[i] != max(A):
        print(max(A))
    else:
        for j in range(N):
            if (A[j] >= mx) & j != i:
                mx = A[j]
        print(mx)