import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())
Anp = np.array(A)

L = np.maximum.accumulate(Anp)
R = np.maximum.accumulate(Anp[::-1])[::-1]

LL = [0] + L.tolist()[:-1]
RR = R.tolist()[1:] + [0]
print(LL)
print(RR)

for x, y in zip(LL, RR):
    print(x if x > y else y)
