from sys import stdin
input = stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

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

