N = int(input())
A = [int(input()) for _ in range(N)]
#print(A)
for i in range(N):
    a = A[:i]
    b = A[i+1:]
    if len(a) == 0:
        a = [0]
    if len(b) == 0:
        b = [0]
    print(max(max(a),max(b)))