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 == 1 and N == 2:
        print(A[0])
    elif i == 1 and N > 2:
        print(max(A[0], max(A[2:])))
    elif i == N -2:
        print(max(max(A[:N-2]), A[N-1]))
    elif i == N - 1:
        print(max(A[:N-1]))
    else:
        print(max(A[:i]),max(A[i+1:]))