N = int(input())
A = []
for n in range(N):
    A.append(int(input()))

for n in range(N):
    max_before = max(A[:n], default=0)
    max_after = max(A[n+1:], default=0)
    ans = max(max_before, max_after)
    print(ans)
