import itertools

n = int(input())
a = [int(input()) for i in range(n)]
max_list = list(itertools.accumulate(a, func=max))
max_list_r = list(itertools.accumulate(reversed(a), func=max))

for i in range(n):
    print(max(max_list[i - 1], max_list_r[i - 1]))
