n = int(input())
A = [int(input()) for _ in range(n)]
if n == 2:
    print(A[1])
    print(A[0])    
else:
    for i in range(n):
        if i == 0:
            print(max(A[1 : ]))
        elif i == n - 1:
            print(max(A[ : n]))
        else:
            a = max(A[ : i])
            b = max(A[i + 1 : ])
            print(max(a, b))