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

for i in range(N):
    if i == 0:
        print(max(A[1:]))
    elif i == N - 1:
        print(max(A[:-1]))
    else:
        a = max(A[:i-1],A[i+1:])
        print(a[0])
        