import sys

input = sys.stdin.readline



import numpy as np



N = int(eval(input()))

A = np.array([int(eval(input())) for _ in range(N)])



from_left = np.maximum.accumulate(A)

from_right = np.maximum.accumulate(A[::-1])[::-1]



from_left, from_right



from_left = [0] + from_left.tolist()[:-1]

from_right = from_right[1:].tolist() + [0]



for x,y in zip(from_left, from_right):

    print((x if x > y else y))
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



import numpy as np



N = int(readline())

A = np.zeros(N+2,np.int32)

A[1:-1] = np.array(read().split(),np.int32)



A



from_left = np.maximum.accumulate(A)

from_right = np.maximum.accumulate(A[::-1])[::-1]



answer = np.maximum(from_left[:-2], from_right[2:])

print(('\n'.join(answer.astype(str))))
import sys

input = sys.stdin.readline
import numpy as np

N = int(eval(input()))
A = np.array([int(eval(input())) for _ in range(N)])
from_left = np.maximum.accumulate(A)
from_right = np.maximum.accumulate(A[::-1])[::-1]
from_left, from_right
from_left = [0] + from_left.tolist()[:-1]
from_right = from_right[1:].tolist() + [0]
for x, y in zip(from_left, from_right):
    print((x if x > y else y))

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

N = int(readline())
A = np.zeros(N + 2, np.int32)
A[1:-1] = np.array(read().split(), np.int32)
A
from_left = np.maximum.accumulate(A)
from_right = np.maximum.accumulate(A[::-1])[::-1]
answer = np.maximum(from_left[:-2], from_right[2:])
print(("\n".join(answer.astype(str))))

-input = sys.stdin.readline +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines -N = int(eval(input())) -A = np.array([int(eval(input())) for _ in range(N)]) +N = int(readline()) +A = np.zeros(N + 2, np.int32) +A[1:-1] = np.array(read().split(), np.int32) +A -from_left, from_right -from_left = [0] + from_left.tolist()[:-1] -from_right = from_right[1:].tolist() + [0] -for x, y in zip(from_left, from_right): -    print((x if x > y else y)) +answer = np.maximum(from_left[:-2], from_right[2:]) +print(("\n".join(answer.astype(str))))