import sys

def main():
    N = int(input())
    A = [int(sys.stdin.readline()) for i in range(N)]


    for j in range(N):
        if j == 0:
            print(max(A[1:]))

        elif j == N-1:
            print(max(A[:N-1]))

        else:
            print(max(max(A[:j]), max(A[j+1:])))


main()