import sys

import numpy as np



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



N = ir()

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

A[1:-1] = np.array([ir() for _ in range(N)])



left_max = np.maximum.accumulate(A[:-2])

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

answer = np.maximum(left_max, right_max)

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

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)



left_max = np.maximum.accumulate(A[:-2])

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

answer = np.maximum(left_max, right_max)

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

import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
A = np.zeros(N + 2, np.int32)
A[1:-1] = np.array([ir() for _ in range(N)])
left_max = np.maximum.accumulate(A[:-2])
right_max = np.maximum.accumulate(A[::-1])[::-1][2:]
answer = np.maximum(left_max, right_max)
print(("\n".join(answer.astype(str))))

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)
left_max = np.maximum.accumulate(A[:-2])
right_max = np.maximum.accumulate(A[::-1])[::-1][2:]
answer = np.maximum(left_max, right_max)
print(("\n".join(answer.astype(str))))

+ +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines -sr = lambda: sys.stdin.readline().rstrip() -ir = lambda: int(sr()) -lr = lambda: list(map(int, sr().split())) -N = ir() +N = int(readline()) -A[1:-1] = np.array([ir() for _ in range(N)]) +A[1:-1] = np.array(read().split(), np.int32)