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(map(str, answer))))

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
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(map(str, answer))))

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))))

-print(("\n".join(map(str, answer)))) +print(("\n".join(answer.astype(str))))