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

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

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

for i in a:
    print(i)