N = int(input())
A = [int(input()) for _ in range(N)]

if N == 2:
    print("\n".join(map(str, A[::-1])))
else:
    for i in range(N):
        if i == N - 1:
            print(max(A[:-1]))
        else:
            print(max(*A[:i], *A[i+1:]))