
def solve():
    for i in range(N):
#        print("----------")
        if i == 0:
            print(max(A[i:N]))
        elif i == N-1:
            print(max(A[:N]))
        else:
            a = max(A[:i])
            b = max(A[i+1:N])
            print(max(a,b))
#        print(A[:i], A[i+1:N])

if __name__ == "__main__":
    N = int(input())
    A = [int(input()) for _ in range(N)]
    solve()
