Alicia has an array, $a_1, a_2, \ldots, a_n$, of non-negative integers. For each $1 \leq i \leq n$, she has found a non-negative integer $x_i = max(0, a_1, \ldots, a_{i-1})$. Note that for $i=1$, $x_i = 0$.

For example, if Alicia had the array $a = \{0, 1, 2, 0, 3\}$, then $x = \{0, 0, 1, 2, 2\}$.

Then, she calculated an array, $b_1, b_2, \ldots, b_n$: $b_i = a_i - x_i$.

For example, if Alicia had the array $a = \{0, 1, 2, 0, 3\}$, $b = \{0-0, 1-0, 2-1, 0-2, 3-2\} = \{0, 1, 1, -2, 1\}$.

Alicia gives you the values $b_1, b_2, \ldots, b_n$ and asks you to restore the values $a_1, a_2, \ldots, a_n$. Can you help her solve the problem?


-----Input-----

The first line contains one integer $n$ ($3 \leq n \leq 200\,000$) – the number of elements in Alicia's array.

The next line contains $n$ integers, $b_1, b_2, \ldots, b_n$ ($-10^9 \leq b_i \leq 10^9$).

It is guaranteed that for the given array $b$ there is a solution $a_1, a_2, \ldots, a_n$, for all elements of which the following is true: $0 \leq a_i \leq 10^9$.


-----Output-----

Print $n$ integers, $a_1, a_2, \ldots, a_n$ ($0 \leq a_i \leq 10^9$), such that if you calculate $x$ according to the statement, $b_1$ will be equal to $a_1 - x_1$, $b_2$ will be equal to $a_2 - x_2$, ..., and $b_n$ will be equal to $a_n - x_n$.

It is guaranteed that there exists at least one solution for the given tests. It can be shown that the solution is unique.


-----Examples-----
Input
5
0 1 1 -2 1

Output
0 1 2 0 3 
Input
3
1000 999999000 -1000000000

Output
1000 1000000000 0 
Input
5
2 1 2 2 3

Output
2 3 5 7 10 


-----Note-----

The first test was described in the problem statement.

In the second test, if Alicia had an array $a = \{1000, 1000000000, 0\}$, then $x = \{0, 1000, 1000000000\}$ and $b = \{1000-0, 1000000000-1000, 0-1000000000\} = \{1000, 999999000, -1000000000\}$.

Difficulty: EASY

Solutions:
n = int(input())
a = list(map(int, input().split()))
ans = 0
ansa = 0
for i in range(n):
	if a[i] > 0:
		ans += a[i]
		print(ans, end=' ')
	else:
		ans += a[i]
		print(ans, end=' ')
		ans -= a[i]


n = int(input())
b = list(map(int, input().split()))
max_element = 0
for i in range(n):
	value = b[i] + max_element
	if value > max_element:
		max_element = value
	print(value, end=' ')


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
from io import BytesIO, IOBase
from bisect import bisect_left as bl
from bisect import bisect_right as br

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def modpow(b, p, m):
	res = 1
	b = b % m
	while p:
		if p & 1:
			res = res * b % m
		b = b * b % m
		p >>= 1
	return res

def mod_inv(a, m):
	return modpow(a, m - 2, m)

def ncr(n, r, m):
	res = 1
	if r == 0:
		return 1
	if n - r < r:
		r = n - r
	(p, k) = (1, 1)
	while r:
		res = res % m * (n % m * mod_inv(r, m) % m) % m
		n -= 1
		r -= 1
	return res

def ncrlis(n, r, m, fact):
	return fact[n] * (mod_inv(fact[r], m) * mod_inv(fact[n - r], m)) % m % m

def dfs(u, lis):
	vis[u] = True
	lis.append(u)
	for v in g[u]:
		if not vis[v]:
			lis = dfs(v, lis)
	return lis

def dfsutil():
	cnc = []
	for i in range(1, n + 1):
		if not vis[i]:
			tmp = []
			cnc.append(dfs(i, tmp))
	return cnc

def bfs(s, prev):
	q = deque()
	q.append(s)
	vis[s] = True
	while q:
		u = q.popleft()
		for v in g[u]:
			if not vis[v]:
				q.append(v)
				vis[v] = True
				prev[v] = u

def path(s, e):
	prev = [False for i in range(n + 1)]
	bfs(s, prev)
	at = e
	res = []
	while at != False:
		res.append(at)
		at = prev[at]
	res.reverse()
	if res[0] == s:
		return res
	else:
		return []

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def ddd():
	return collections.defaultdict(collections.defaultdict(int))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = ii()
b = li()
maxa = [0 for i in range(n)]
a = [0 for i in range(n)]
a[0] = b[0]
maxa[0] = b[0]
for i in range(1, n):
	a[i] = b[i] + maxa[i - 1]
	maxa[i] = max(maxa[i - 1], a[i])
print(*a)


arraySize = int(input())
bArray = input()
bArray = list(bArray.split(' '))
xArray = [0]
aArray = [int(bArray[0])]
max = aArray[0]
for i in range(1, arraySize):
	aArray.append(int(bArray[i]) + max)
	if aArray[i] > max:
		max = aArray[i]
for i in range(0, len(aArray)):
	print(aArray[i], end=' ')


n = int(input())
b = list(map(int, input().split()))
a = [0] * (len(b) + 1)
x = []
maxx = 0
for i in range(1, len(b) + 1):
	a[i] = b[i - 1] + maxx
	maxx = max(a[i], maxx)
a.pop(0)
for i in a:
	print(i, end=' ')


n = int(input())
l = list(map(int, input().split()))
s = [l[0]]
t = l[0]
for i in range(1, n):
	s.append(t + l[i])
	t = max(t, l[i] + t)
print(*s)


n = int(input())
b = list(map(int, input().split()))
a = [b[0]]
x = b[0]
for i in range(1, n):
	a.append(b[i] + x)
	x = max(x, a[-1])
print(*a)


n = int(input())
bs = [int(i) for i in input().split()]
current = 0
xs = []
for b in bs:
	if b >= 0:
		current += b
		xs.append(current)
	else:
		xs.append(current + b)
print(' '.join(map(str, xs)))


n = int(input())
b = list(map(int, input().split()))
m = 0
for i in range(n):
	b[i] += m
	print(b[i], end=' ')
	m = max(m, b[i])


n = int(input())
b = list(map(int, input().split()))
aMax = 0
for i in range(len(b)):
	x = aMax
	a = x + b[i]
	if a > aMax:
		aMax = a
	print(a, end=' ')


n = int(input())
b = list(map(int, input().split()))
a = [0 for i in range(n + 2)]
maxx = 0
for i in range(len(b)):
	a1 = b[i] + maxx
	a[i + 1] = a1
	if a[i + 1] > maxx:
		maxx = a[i + 1]
for i in range(1, n + 1):
	print(a[i], end=' ')


def construct(b):
	best = max(0, b[0])
	a = [b[0]]
	x = [0]
	for i in range(1, len(b)):
		x.append(best)
		a.append(x[i] + b[i])
		best = max(best, a[i])
	return a
n = int(input())
arr = list(map(int, input().split()))
print(' '.join(map(str, construct(arr))))


import sys
from math import *
from collections import defaultdict
from queue import deque
from heapq import heappush, heappop
lines = [line.strip() for line in sys.stdin.readlines()]
n = int(lines[0])
bs = list(map(int, lines[1].split()))
xs = [0]
ys = []
for b in bs:
	ys += [b + xs[-1]]
	xs += [max(ys[-1], xs[-1])]
print(' '.join(map(str, ys)))


def Maximums():
	x = []
	b = []
	a = []
	cnt = 0
	n = int(input())
	b = [int(x) for x in input().split(' ')]
	for i in range(n):
		a.append(b[i] + cnt)
		x.append(cnt)
		if b[i] + cnt > cnt:
			cnt = b[i] + cnt
	print(' '.join((str(x) for x in a)))
Maximums()


n = int(input())
arr = list(map(int, input().split()))
ans = [0] * n
mm = arr[0]
ans[0] = arr[0]
for i in range(1, n):
	ans[i] = arr[i] + mm
	mm = max(mm, ans[i])
print(*ans)


n = int(input())
B = list(map(int, input().split()))
A = [0 for _ in range(n)]
A[0] = B[0]
X = [0 for _ in range(n)]
for i in range(1, n):
	X[i] = max(X[i - 1], A[i - 1])
	A[i] = B[i] + X[i]
for i in range(n - 1):
	print(A[i], end=' ')
print(A[n - 1])


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

def getVars():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def getStr():
	return input().strip()
n = getInt()
b = getList()
a = []
a.append(b[0])
a.append(b[1] + b[0])
m = max(b[0], b[1])
for i in range(2, n):
	m = max(m, a[i - 1])
	a.append(b[i] + m)
print(*a)


num = int(input())
numbers = input().split(' ')
a = [0] * num
ma = 0
for i in range(num):
	new = ma + int(numbers[i])
	a[i] = str(new)
	ma = max(ma, new)
print(' '.join(a))


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	ans = [arr[0]]
	x = 0
	a = arr[0]
	for i in range(1, n):
		x = max(x, a)
		ans.append(arr[i] + x)
		a = ans[-1]
	for i in ans:
		print(i, end=' ')
main()


n = int(input())
b = list(map(int, input().split()))
a = []
msf = 0
for i in range(n):
	ai = b[i] + msf
	msf = max(ai, msf)
	a += [ai]
print(*a)


def solve():
	num = int(input())
	BARR = list(map(int, input().split()))[0:num]
	ARRAY = []
	ELEXT = []
	ELEXT.append(0)
	for i in range(0, num):
		ARRAY.insert(i, BARR[i] + ELEXT[i])
		if ELEXT[i] > ARRAY[i]:
			ELEXT.insert(i + 1, ELEXT[i])
		else:
			ELEXT.insert(i + 1, ARRAY[i])
	for i in range(0, num):
		print(ARRAY[i], end=' ')
solve()


n = int(input())
l = list(map(int, input().split()))
(z, s) = ([], 0)
for x in range(n):
	if l[x] >= 0:
		s += l[x]
		z.append(s)
	else:
		z.append(s + l[x])
		l[x] = 0
print(*z)


a = int(input())
b = input().split()
add = 0
new = 0
k = []
for i in b:
	if int(i) > 0:
		add = add + int(i)
		new = add
	else:
		new = add + int(i)
	k.append(new)
print(k[0], end='')
for i in k[1:]:
	print(' ', end='')
	print(i, end='')


n = int(input())
b = [int(i) for i in input().split()]
a = [0] * len(b)
a[0] = b[0]
a[1] = b[1] + a[0]
currMax = max(a[0], a[1])
for i in range(2, len(a)):
	if a[i - 1] > currMax:
		currMax = a[i - 1]
	a[i] = b[i] + currMax
print(*a)


n = int(input())
b = list(map(int, input().split()))
x = 0
a = [0] * n
for i in range(n):
	a[i] += x + b[i]
	x = max(x, a[i])
print(*a, sep=' ')


t = int(input())
a = list(map(int, input().split(' ')))
max = a[0]
for i in range(1, t):
	a[i] = a[i] + max
	if max < a[i]:
		max = a[i]
for i in a:
	print(str(i), end=' ')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
nums = int(input())
bs = list(map(int, input().split()))
outputlist = [str(bs[0])]
highest = bs[0]
for j in range(1, nums):
	outputlist.append(str(bs[j] + highest))
	if int(outputlist[-1]) > highest:
		highest = int(outputlist[-1])
print(' '.join(outputlist))


def get_initial_seq(n, b):
	a = [0 for i in range(n)]
	max_val = 0
	for i in range(n):
		if i == 0:
			a[i] = b[i]
		else:
			max_val = max(max_val, a[i - 1])
			a[i] = b[i] + max_val
	return a
array_size = int(input())
b = list(input().split(' '))
b = [int(i) for i in b]
res = get_initial_seq(array_size, b)
print(' '.join(map(str, res)))


n = int(input())
b = list(map(int, input().split()))
a = b[0]
print(a, end=' ')
last_x = 0
for i in range(1, n):
	new_last_x = max(last_x, a)
	a = b[i] + max(last_x, a)
	last_x = new_last_x
	print(a, end=' ')
print()


n = int(input())
b = [int(x) for x in input().split()]
x = []
a = []
x.append(0)
m = 0
for i in range(n):
	a.append(b[i] + x[-1])
	m = max(m, a[-1])
	x.append(m)
for i in a:
	print(i, end=' ')


x = [0]
a = []
n = int(input())
b = list(map(int, input().split()))
for num in b:
	a.append(num + x[-1])
	x.append(max(x[-1], a[-1]))
print(*a, sep=' ')


from fractions import Fraction
from collections import defaultdict
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
for _ in range(1):
	n = int(input())
	l = list([int(x) for x in input().split()])
	nl = []
	x = 0
	for i in l:
		i += x
		nl.append(i)
		x = max(x, i)
	print(*nl)


x = int(input())
d = list(map(int, input().split()))
g = []
g.append(0)
f = g[0]
for i in range(len(d)):
	l = d[i] + f
	if l > f:
		f = l
	print(l, end=' ')
	g.append(l)


n = int(input())
b = [int(i) for i in input().split()]
a = [0] * n
mx = 0
for i in range(n):
	a[i] = b[i] + mx
	mx = max(mx, a[i])
print(*a)


n = int(input())
brr = list(map(int, input().split()))
arr = [0] * n
maxi = 0
for i in range(n):
	arr[i] = maxi + brr[i]
	maxi = max(maxi, arr[i])
print(*arr)


n = int(input())
a = []
b = list(map(int, input().split()))
a.append(b[0] + 0)
mx = a[0]
for j in range(1, n):
	a.append(mx + b[j])
	if a[-1] > mx:
		mx = a[-1]
print(' '.join(list(map(str, a))))


n = int(input())
arr = list(map(int, input().split()))
pref = [0] * n
pref[0] = arr[0]
max1 = arr[0]
for i in range(1, n):
	pref[i] = max1 + arr[i]
	if pref[i] > max1:
		max1 = pref[i]
for i in range(n):
	print(pref[i], end=' ')
print('')


n = int(input())
b = list(map(int, input().split()))
xi = 0
a = [b[0]]
ai = b[0]
for i in range(n - 1):
	co = ai + b[i + 1]
	a.append(co)
	ai = max(ai, co)
print(*a, sep=' ')


t = int(input())
b = input().split()
b = [int(b1) for b1 in b]
a = []
a.append(b[0])
temp = 0
for s in range(1, len(b)):
	temp = max(temp, a[s - 1])
	a.append(b[s] + temp)
print(*a, sep=' ')


n = int(input())
t = list(map(int, input().split()))
m = 0
a = []
a.append(t[0])
print(t[0], end=' ')
for i in range(1, n):
	m = max(m, a[i - 1])
	a.append(t[i] + m)
	print(a[i], end=' ')


n = int(input())
B = [int(i) for i in input().split()]
A = [0] * n
prevMax = 0
for i in range(n):
	A[i] = B[i] + prevMax
	if A[i] > prevMax:
		prevMax = A[i]
print(' '.join((str(x) for x in A)))


n = int(input())
b = list(map(int, input().split()))
from copy import copy
a = copy(b)
m = 0
for i in range(n):
	a[i] += m
	if a[i] > m:
		m = a[i]
print(' '.join(map(str, a)))


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def case():
	n = int(input())
	a = li()
	s = 0
	m = 0
	for i in a:
		i = m + i
		m = max(m, i)
		print(i, end=' ')
for _ in range(1):
	case()


n = int(input())
arr = list(map(int, input().split()))
pref = [arr[0]]
m = arr[0]
for i in arr[1:]:
	a = i + m
	pref.append(a)
	m = max(a, m)
print(*pref)


n = int(input())
l = list(map(int, input().split()))
a = []
for i in range(n):
	if i == 0:
		a.append(l[i])
		k = l[i]
	else:
		c = l[i] + k
		a.append(c)
		if c > k:
			k = c
print(*a)


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():
	n = int(input())
	bb = [int(a) for a in input().split()]
	aa = []
	mx = 0
	for b in bb:
		aa.append(b + mx)
		mx = max(aa[-1], mx)
	print(' '.join(map(str, aa)))
main()


t = int(input())
b = list(map(int, input().split()))
a = [b[0]]
k = 0
for i in range(1, len(b)):
	a.append(max(k, a[i - 1]) + b[i])
	k = max(k, a[i - 1])
a1 = ''
for i in a:
	a1 += str(i) + ' '
print(a1)


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
b = [int(x) for x in inp().split()]
a = []
aElement = 0
for i in b:
	a.append(aElement + i)
	if i > 0:
		aElement += i
print(*a)


n = int(input())
arr = list(map(int, input().split()))
negative = False
temp = [None for i in range(n)]
temp[0] = arr[0]
for i in range(1, n):
	if arr[i] < 0:
		negative = True
	temp[i] = temp[i - 1] + arr[i]
	if arr[i - 1] < 0:
		temp[i] = temp[i] - arr[i - 1]
print(*temp)


import sys
input = sys.stdin.readline

def multi_input():
	return map(int, input().split())

def array_print(arr):
	print(' '.join(map(str, arr)))
n = int(input())
a = list(multi_input())
max1 = a[0]
for i in range(1, n):
	a[i] = a[i] + max1
	max1 = max(a[i], max1)
print(' '.join(map(str, a)))


n = int(input())
arr = list(map(int, input().split()))
ok = 0
for i in range(len(arr)):
	print(ok + arr[i], end=' ')
	ok = max(ok + arr[i], ok)


n = int(input())
a = list(map(int, input().split()))
b = [a[0]]
mx = a[0]
for aa in a[1:]:
	b.append(aa + mx)
	mx = max(b[-1], mx)
print(*b)


def solve(n, b):
	a = []
	a.append(b[0])
	curr_max = max(0, a[0])
	for i in range(1, n):
		a.append(b[i] + curr_max)
		curr_max = max(curr_max, a[i])
	for val in a:
		print(val, '', end='')
n = int(input())
b = [int(x) for x in input().split()]
solve(n, b)


n = int(input())
b = list(map(int, input().split()))
a = []
a.append(b[0])
a.append(b[1] + b[0])
maxi = max(a)
for i in range(2, n):
	if maxi < a[i - 1]:
		maxi = a[i - 1]
	a.append(maxi + b[i])
print(*a)


n = int(input())
arr = list(map(int, input().split()))
act = [0] * n
act[0] = arr[0]
m = arr[0]
for i in range(1, n):
	act[i] = max(m, act[i - 1]) + arr[i]
	m = max(act[i], m)
print(*act)


n = int(input())
k = 0
v = []
b = list(map(int, input().split()))
for i in range(len(b)):
	if b[i] < 0:
		v.append(k + b[i])
		continue
	else:
		k += b[i]
		v.append(k)
for i in v:
	print(i, end=' ')


n = int(input())
line = map(int, input().split())
maxmum = 0
for value in line:
	print(value + maxmum, end=' ')
	if value + maxmum > maxmum:
		maxmum = value + maxmum


n = int(input())
numbers = list(map(int, input().split()))
result = []
m = 0
for (index, number) in enumerate(numbers):
	if not result:
		result.append(number)
		m = number
	else:
		result.append(m + number)
		if m + number > m:
			m = m + number
print(' '.join(map(str, result)))


def answer(Barr):
	Aarr = [0] * len(Barr)
	Xarr = [0, 0] + [0] * (len(Barr) - 2)
	Aarr[0] = Barr[0]
	Xarr[0] = Aarr[0]
	for i in range(1, len(Barr)):
		Xarr[i] = Aarr[i - 1] if Xarr[i - 1] < Aarr[i - 1] else Xarr[i - 1]
		Aarr[i] = Barr[i] + Xarr[i]
	return ' '.join([str(e) for e in Aarr])
_ = int(input())
Barr = list(map(int, input().split()))
print(answer(Barr))


n = int(input())
my_list = [int(x) for x in input().split(' ')]
new_list = [my_list[0]]
x = 0
for i in range(1, n):
	x = max(x, new_list[i - 1])
	new_list.append(x + my_list[i])
for x in new_list:
	print(x, end=' ', sep=' ')
print()


n = int(input())
s = input().split(' ')
a = [0] * n
for i in range(n):
	a[i] = int(s[i])
max1 = a[0]
b = [0] * n
b[0] = a[0]
for i in range(1, n):
	b[i] = max1 + a[i]
	if a[i] > 0:
		max1 += a[i]
s1 = ''
for i in range(n):
	s1 += str(b[i]) + ' '
print(s1)


n = int(input())
b = list(map(int, input().split()))
ans = []
mx = 0
for val in b:
	ans.append(val + mx)
	mx = max(ans[-1], mx)
print(*ans)


n = int(input())
a = list(map(int, input().split()))
x = []
ma = 0
for i in range(n):
	x.append(a[i] + ma)
	ma = max(x[-1], ma)
print(' '.join(map(str, x)))


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))

def solve():
	n = ri()
	B = rl()
	A = []
	m = 0
	for b in B:
		A.append(b + m)
		if b > 0:
			m += b
	print(*A)
mode = 's'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


n = int(input())
a = [-1] * n
x = [-1] * n
b = [int(i) for i in input().split()]
a[0] = b[0]
x[0] = 0
for i in range(1, n):
	x[i] = max(x[i - 1], a[i - 1])
	a[i] = b[i] + x[i]
print(*a)


i = int(input())
res = list(map(int, input().split()))
ans = [0] * len(res)
ans[0] = res[0]
mins = res[0]
for i in range(1, len(res)):
	mins = max(mins, ans[i - 1])
	ans[i] = res[i] + mins
for j in ans:
	print(j, end=' ')


def maximum():
	n = int(input())
	b = [int(num) for num in input().split()]
	a = [b[0]]
	y = 0
	for i in range(1, n):
		x = b[i] + max(y, a[i - 1])
		y = max(y, a[i - 1])
		a.append(x)
	for j in range(0, n):
		print(a[j], end=' ')
maximum()


import math

def main():
	print(case())

def case():
	n = int(input())
	b = list(map(int, input().split()))
	a = []
	a.append(abs(b[0]))
	m = b[0]
	for i in range(1, n):
		a.append(m + b[i])
		if a[-1] > m:
			m = a[-1]
	return ' '.join(map(str, a))
main()


import heapq

def one():
	return int(input())

def more():
	return map(int, input().split())
n = one()
b = list(more())
mx = 0
a = [b[0]]
mx = max(mx, a[0])
for i in range(1, n):
	a.append(b[i] + mx)
	mx = max(mx, a[-1])
for i in a:
	print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
c = 0
for i in range(n):
	ans[i] = c + a[i]
	c = max(c, ans[i])
print(' '.join(map(str, ans)))


n = int(input())
b = list(map(int, input().split()))
x = 0
for i in b:
	a1 = i + x
	print(a1, end=' ')
	x = max(a1, x)


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	n = II()
	bb = LI()
	aa = [0] * n
	xx = [0] * n
	aa[0] = bb[0]
	for i in range(1, n):
		xx[i] = max(aa[i - 1], xx[i - 1])
		aa[i] = bb[i] + xx[i]
	print(*aa)
main()


n = int(input())
b = [int(x) for x in input().split()]
a = [0] * n
a[0] = b[0]
ss = a[0]
for i in range(1, n):
	a[i] = b[i] + ss
	if a[i] > ss:
		ss = a[i]
print(*a)


from sys import stdin
input = stdin.readline

def main():
	n = int(input())
	l = [int(i) for i in input().split(' ')]
	ans = [0 for i in range(n)]
	val = 0
	for i in range(n):
		ans[i] = val + l[i]
		val = max(val, ans[i])
	for i in ans:
		print(i, end=' ')
main()


n = int(input())
a = list(map(int, input().split()))
ans = []
max1 = 0
for i in a:
	ans.append(i + max1)
	if i + max1 > max1:
		max1 = i + max1
for i in ans:
	print(i, end=' ')
print()


n = int(input())
a = list(map(int, input().split()))
print(a[0], end=' ')
x = max(a[0], 0)
for i in range(1, len(a)):
	print(a[i] + x, end=' ')
	if x < a[i] + x:
		x = a[i] + x


n = int(input())
b = [int(i) for i in input().split()]
x = len(b) * [0]
a = len(b) * [0]
a[0] = b[0] + x[0]
mx = a[0]
print(a[0], end=' ')
for i in range(1, len(b)):
	x[i] = mx
	a[i] = b[i] + x[i]
	mx = max(a[i], mx)
	print(a[i], end=' ')


n = int(input())
b = [int(x) for x in input().split()]
a = []
mm = 0
a.append(0)
for i in range(n):
	a.append(b[i] + max(a[i], mm))
	if a[i] > mm:
		mm = a[i]
print(*a[1:])


c = int(input())
b = [int(i) for i in input().split()]
a = [0 for i in range(c)]
a[0] = b[0]
ma = a[0]
for i in range(1, c):
	a[i] = ma + b[i]
	ma = max(a[i], ma)
print(*a)


def main():
	import sys
	input = sys.stdin.readline
	N = int(input())
	B = list(map(int, input().split()))
	A = [0] * N
	X = [0] * N
	M = 0
	for i in range(N):
		X[i] = M
		A[i] = B[i] + X[i]
		M = max(M, A[i])
	print(*A)
main()


n = int(input())
bl = list(map(int, input().split()))
al = []
max_a = 0
for i in range(n):
	ans = bl[i] + max_a
	al.append(ans)
	max_a = max(max_a, ans)
print(*al)


b = int(input())
a = list(map(int, input().split()))
x = 0
c = []
for k in range(b):
	print(a[k] + x, end=' ')
	if a[k] + x > x:
		x = a[k] + x


n = int(input())
a = list(map(int, input().split()))
if n == 1:
	print(a[0])
elif n == 2:
	print(a[0] + a[1])
else:
	b = []
	b.append(a[0])
	b.append(a[0] + a[1])
	m = b[0]
	for i in range(2, n):
		m = max(m, b[-1])
		b.append(m + a[i])
	for i in b:
		print(i, end=' ')


import sys
input = sys.stdin.readline
from math import *
n = int(input())
b = [int(x) for x in input().split()]
a = [0 for i in range(n)]
prev = 0
for i in range(n):
	if b[i] == 0:
		a[i] = prev
	else:
		a[i] = prev + b[i]
		prev = max(prev, b[i] + prev)
print(*a)


n = int(input())
b = list(map(int, input().split(' ')))
a = []
max = 0
for i in range(n):
	next = b[i] + max
	a.append(next)
	if next > max:
		max = next
a = list(map(str, a))
print(' '.join(a))


n = int(input())
arr = list(map(int, input().split()))
ans = []
mx = arr[0]
for i in range(len(arr)):
	if i < 1:
		ans.append(arr[i])
	else:
		ans.append(mx + arr[i])
	mx = max(mx, ans[-1])
for i in ans:
	print(i, end=' ')


n = int(input())
l = list(map(int, input().split()))
max_yet = l[0]
for i in range(1, n):
	l[i] = l[i] + max_yet
	if l[i] > max_yet:
		max_yet = l[i]
for i in range(n):
	print(l[i], end=' ')


n = int(input())
b = list(map(int, input().split()))
a = [0] * n
a[0] = b[0]
a[1] = b[1] + a[0]
formerMax = max(a[0], a[1])
for i in range(2, n):
	a[i] = b[i] + formerMax
	formerMax = max(formerMax, a[i])
print(*a)


n = int(input())
b = [int(x) for x in input().split()]
a = []
mx = 0
for x in b:
	if x >= 0:
		mx += x
		a.append(mx)
	else:
		a.append(mx + x)
print(' '.join(map(str, a)))


def main():
	m = 0
	input()
	for i in input().split(' '):
		result = m + int(i)
		if result > m:
			m = result
		print(result, end=' ')
main()


n = int(input())
bi = list(map(int, input().split()))
cur_max = 0
for i in range(n):
	ai = bi[i] + cur_max
	print(ai, end=' ')
	cur_max = max(cur_max, ai)


import sys
import math
input = sys.stdin.readline
t = 1
for _ in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	mini = 0
	a = []
	for i in range(n):
		a.append(b[i] + mini)
		mini = max(a[-1], mini)
	for i in range(n):
		print(a[i], end=' ')


n = int(input())
b = list(map(int, input().split()))
a = []
maxima = 0
for x in b:
	a.append(x + maxima)
	maxima = max(x + maxima, maxima)
print(*a)


n = int(input())
l = list(map(int, input().split()))
l1 = [0] * n
sum1 = 0
for i in range(len(l)):
	if l[i] > 0:
		sum1 += l[i]
		l1[i] = sum1
	else:
		l1[i] = sum1 + l[i]
for i in range(len(l1)):
	print(l1[i], end=' ')


from sys import stdin
from collections import defaultdict, Counter
from math import gcd
T = int(input())
b = list(map(int, stdin.readline().split()))
a = [b[0]]
r_max = b[0]
for i in range(1, len(b)):
	a.append(r_max + b[i])
	r_max = max(r_max, r_max + b[i])
print(' '.join(map(str, a)))


t = int(input())
l = [int(x) for x in input().split()]
k = []
k.append(str(l[0]))
sum1 = 0
sum1 = l[0]
for i in range(1, t):
	if l[i] > 0:
		sum1 = sum1 + l[i]
		k.append(str(sum1))
	else:
		k.append(str(sum1 + l[i]))
print(' '.join(k))


n = int(input())
b = [int(o) for o in input().split()]
c = []
y = []
y.append(0)
c.append(b[0])
for i in range(1, n):
	temp = max(y[-1], c[-1])
	y.append(temp)
	c.append(b[i] + y[i])
print(*c)


from sys import stdin
inp = stdin.readline
n = int(inp())
b = list(map(int, inp().split()))
a = []
g = 0
for i in range(n):
	a.append(b[i] + g)
	g = max(g, a[-1])
for u in range(n):
	print(a[u], end=' ')


t = int(input())
arr = list(map(int, input().split()))
su = 0
su_wi = 0
ls = []
for i in arr:
	if i >= 0:
		su += i
		ls.append(su)
	else:
		ls.append(su + i)
print(' '.join(map(str, ls)))


N = int(input())
numbers = list(map(int, input().split()))
a = []
x = [0]
highest = numbers[0]
for i in range(N):
	a.append(x[i] + numbers[i])
	if x[i] + numbers[i] > highest:
		highest = numbers[i] + x[i]
	x.append(highest)
print(' '.join([str(e) for e in a]))


listlength = input()
listlength = int(listlength)
x = input().split(' ')
x = list(map(int, x))
a = []

def build_list(a):
	amax = 0
	current = 0
	for i in range(listlength):
		current = amax + x[i]
		a.append(current)
		if current > amax:
			amax = current
	return a
print(*build_list(a), sep=' ')


n = int(input())
b = [int(i) for i in input().split()]
a = [b[0]]
sm = b[0]
mx = b[0]
for i in range(1, n):
	if b[i] >= 0:
		sm += b[i]
		a.append(sm)
	else:
		a.append(mx + b[i])
	if a[i] > mx:
		mx = a[i]
for i in a:
	print(i, end=' ')
print()


n = int(input())
b = list(map(int, input().rstrip().split()))
a = [b[0]]
tmp = b[0]
for i in range(1, n):
	if b[i] > 0:
		a.append(tmp + b[i])
		tmp = a[-1]
	elif b[i] <= 0:
		a.append(tmp + b[i])
for i in a:
	print(i, end=' ')


n = int(input())
b = list(map(int, input().split()))
a = b[0]
print(a, end=' ')
for num in range(1, n):
	print(b[num] + a, end=' ')
	if b[num] + a > a:
		a = b[num] + a


n = int(input())
l = list(map(int, input().split()))
resarr = [l[0]]
actualmax = l[0]
for i in range(1, n):
	if l[i] > 0:
		resarr.append(actualmax + l[i])
		actualmax += l[i]
	else:
		resarr.append(actualmax + l[i])
print(*resarr)


input()
x = 0
for i in map(int, input().split()):
	print(i + x, end=' ')
	x = x + max(0, i)


n = int(input())
c = list(map(int, input().split()))
l = []
tot = c[0]
l.append(tot)
m = max(l)
for i in range(1, len(c)):
	l.append(c[i] + m)
	if c[i] + m > m:
		m = c[i] + m
print(*l)


n = int(input())
b = list(map(int, input().split()))
a = []
a.append(b[0])
m = b[0]
for i in range(1, n):
	if a[i - 1] > m:
		m = a[i - 1]
	a.append(b[i] + m)
print(*a)


def solver(input_list):
	result = []
	for (idx, item) in enumerate(input_list):
		if idx == 0:
			result.append(item)
			prev = item
			continue
		updated = prev + item
		result.append(updated)
		prev = max(updated, prev)
	return ' '.join(list(map(lambda x: str(x), result)))
n = input()
input_list = []
for i in input().split(' '):
	input_list.append(int(i))
print(solver(input_list))


n = int(input())
q = [int(x) for x in input().split()]
ans = [q[0]]
maxNum = q[0]
for i in range(1, len(q)):
	maxNum = max(maxNum, ans[i - 1])
	ans.append(q[i] + maxNum)
print(*ans)


n = int(input())
b = list(map(int, input().split()))
i = 0
maximum = 0
while i != n:
	print(b[i] + maximum, end=' ')
	maximum = max(b[i] + maximum, maximum)
	i += 1


import sys
inp = sys.stdin.readline

def input():
	return inp().strip()

def iin():
	return int(input())

def lin():
	return list(map(int, input().split()))

def main():
	T = 1
	while T:
		T -= 1
		n = iin()
		b = lin()
		a = [b[0]]
		mx = a[0]
		for i in range(1, n):
			x = b[i]
			a.append(mx + x)
			mx += max(0, x)
		print(*a)
main()


t = int(input())
n = list(map(int, input().split()))
print(n[0], end=' ')
x = n[0]
for i in range(1, t):
	print(n[i] + x, end=' ')
	if n[i] + x > x:
		x = x + n[i]


import sys
input = sys.stdin.readline
n = int(input())
b = list(map(int, input().split()))
a = [b[0], b[1] + b[0]]
maxa = max(a)
for i in range(2, n):
	temp = maxa + b[i]
	a.append(temp)
	if temp > maxa:
		maxa = temp
for i in a:
	print(i, end=' ')
print()


n = int(input())
b = list(map(int, input().split()))
a = []
c = [0]
big = 0
for y in range(len(b)):
	pro = b[y] + c[y]
	a.append(str(pro))
	if big > pro:
		c.append(big)
	else:
		c.append(pro)
		big = pro
print(' '.join(a))


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()
n = ii()
a = li()
x = 0
for i in a:
	print(x + i, end=' ')
	if i > 0:
		x += i


n = input()
m = 0
for b in map(int, input().split()):
	print(b + m, end=' ')
	m = max(m, b + m)


class Solution:

	def __init__(self):
		self.n = int(input())
		self.b = [int(x) for x in input().split()]

	def solve_and_print(self):
		a = [0] * self.n
		a[0] = max_till_i_minus_1 = self.b[0]
		for i in range(1, self.n):
			a[i] = self.b[i] + max_till_i_minus_1
			max_till_i_minus_1 = max(max_till_i_minus_1, a[i])
		print(*a)
Solution().solve_and_print()


t = int(input())
b = list(map(int, input().split()))
max = 0
a = [0] * t
for i in range(t):
	a[i] = max + b[i]
	if b[i] > 0:
		max = max + b[i]
for h in range(t):
	print(a[h], end=' ')


input()
arr = list(map(int, input().split()))
ret = [arr[0]]
best = arr[0]
for e in arr[1:]:
	ret.append(best + e)
	if e > 0:
		best += e
print(' '.join(map(str, ret)))


n = int(input())
b = input().split()
b = [int(x) for x in b]
a = []
large = b[0]
a.append(str(b[0]))
for i in range(1, len(b)):
	val = b[i] + large
	a.append(str(val))
	large = max(val, large)
print(' '.join(a))


N = int(input())
B = list(map(int, input().split()))
ANS = []
max_ans = 0
for b in B:
	if b >= 0:
		max_ans += b
		ANS.append(max_ans)
	else:
		ANS.append(max_ans + b)
print(*ANS)


n = int(input())
l = [int(i) for i in input().split()][:n]
x = 0
a = []
for i in range(n):
	a.append(l[i] + x)
	x += max(0, l[i])
print(*a, sep=' ')


n = int(input())
b = [int(x) for x in input().split()]
x = 0
for i in range(len(b)):
	b[i] += x
	x = max(x, b[i])
for i in range(len(b)):
	print(b[i], end=' ')


n = int(input())
a = [0] * n
b = list(map(int, input().split()))
c = 0
print
for i in range(n):
	a[i] = b[i] + c
	if c <= a[i]:
		c = a[i]
print(*a)


n = int(input())
b = list(map(int, input().split()))
a = []
p = 0
for i in b:
	a.append(i + p)
	p = max(p, i + p)
print(*a)


n = int(input())
b = [int(j) for j in input().split()]
a = [b[0]]
x = [0, a[0]]
i = 1
xi = a[0]
while i < n:
	ai = b[i] + x[i]
	a.append(ai)
	xi = max(xi, ai)
	x.append(xi)
	i += 1
a = [str(j) for j in a]
print(' '.join(a))


n = int(input())
lis = [int(x) for x in input().split()]
result = []
result.append(lis[0])
sums = lis[0]
for i in range(1, len(lis)):
	if lis[i] > 0:
		sums += lis[i]
		result.append(sums)
	else:
		newman = sums + lis[i]
		result.append(newman)
for items in result:
	print(items, end=' ')
print()


from collections import Counter
from collections import defaultdict
import math
n = int(input())
a = list(map(int, input().split()))
l = [0] * n
l[0] = a[0]
x = a[0]
l[0] = a[0]
for i in range(1, n):
	l[i] = a[i] + x
	x = max(x, l[i])
print(*l)


from array import *
counter = 0
n = int(input())
data = array('i', [])
a = map(int, input().split())
data = list(a)
x = 0
while x < n:
	cur = data[x]
	counter = counter + cur
	print(counter, end=' ')
	x = x + 1
	if cur < 0:
		counter = counter - cur


from sys import stdin
r = stdin.readline

def main():
	n = int(r())
	A = list(map(int, r().strip().split()))
	(ans, mx) = ([], 0)
	for x in A:
		if x >= 0:
			ans.append(mx + x)
			mx += x
		else:
			ans.append(mx + x)
	print(*ans)
main()


n = int(input())
b = [int(__) for __ in input().split()]
a = [b[0], b[0] + b[1]]
max_ = max(b[0], b[1])
for i in range(2, n):
	if max_ < a[i - 1]:
		max_ = a[i - 1]
	a.append(b[i] + max_)
for i in a:
	print(i, end=' ')
print('')


import sys

def main():
	n = int(sys.stdin.readline())
	b = [int(j) for j in sys.stdin.readline().split()]
	a = [0] * n
	max_till = 0
	for i in range(n):
		a[i] = b[i] + max_till
		max_till = max(a[i], max_till)
	sys.stdout.write(' '.join([str(x) for x in a]))
	sys.stdout.write('\n')
main()


n = int(input())
a = list(map(int, input().split()))
res = []
m = 0
for i in a:
	res.append(str(m + i))
	if i >= 0:
		m += i
print(' '.join(res))


N = int(input())
arr = list(map(int, input().split()))
arr = [0] + arr
prevmax = 0
for i in range(1, N + 1):
	if i == 1:
		arr[i] = arr[i] + max(arr[:i])
	else:
		prevmax = max(prevmax, arr[i - 1])
		arr[i] = arr[i] + prevmax
A = arr[1:]
for i in A:
	print(i, end=' ')


x = 0
a = []
n = int(input())
b = tuple(map(int, input().split()))
for i in range(n):
	a.append(x + b[i])
	x = max([x, a[-1]])
print(' '.join(map(str, a)))


k = int(input())
b_list = [int(i) for i in input().split()]
a_list = []
x_max = 0
for i in range(k):
	a_list.append(b_list[i] + x_max)
	x_max = max(x_max, a_list[i])
for i in range(k):
	print(a_list[i], end=' ')
print()


n = int(input())
b = list(map(int, input().split()))
a = [b[0]] + [0] * (n - 1)
k = 0
for i in range(1, n):
	if a[i - 1] > k:
		k = a[i - 1]
	a[i] = k + b[i]
for i in range(n):
	print(a[i], end=' ')


n = int(input())
k = list(map(int, input().split()))
a = [0] * n
c = k[0]
a[0] = k[0]
for i in range(1, n):
	a[i] = k[i] + c
	c = max(a[i], c)
print(*a)


def maximums(n, b):
	a = [None] * n
	a[0] = b[0]
	current_x = max(0, a[0])
	for i in range(1, n):
		a_of_i = b[i] + current_x
		a[i] = a_of_i
		current_x = max(current_x, a_of_i)
	return ' '.join((str(a_of_i) for a_of_i in a))
n = int(input())
b = list(map(int, input().split(' ')))
print(maximums(n, b))


n = int(input())
li = list(map(int, input().split()))
res = 0
for i in li:
	print(i + res, end=' ')
	res += max(0, i)


n = int(input())
ar = list(map(int, input().split()))[:n]
k = 0
for i in range(0, n):
	ar[i] = k + ar[i]
	k = max(k, ar[i])
print(*ar)


import sys
input = sys.stdin.readline

def main():
	N = int(input())
	B = [int(x) for x in input().split()]
	A = []
	A.append(B[0])
	ma = B[0]
	for b in B[1:]:
		A.append(b + ma)
		ma = max(ma, b + ma)
	print(*A)
main()


a = int(input())
ary = map(int, input().split())
ary = list(ary)
z = ary[0]
max = z
print(z, end=' ')
for i in range(a - 1):
	if max > z:
		z = max + ary[i + 1]
		print(max + ary[i + 1], end=' ')
	else:
		max = z
		z = max + ary[i + 1]
		print(z, end=' ')


n = int(input())
b = list(map(int, input().split()))
soma = 0
aux = []
maior = 0
for i in range(n - 1):
	if b[i] > maior:
		maior = b[i]
	b[i + 1] += maior
	maior += 0
b = list(map(str, b))
print(' '.join(b))


n = int(input())
b = [int(i) for i in input().split()]
a = []
for i in range(n):
	if i == 0:
		a.append(b[i])
		m = 0
	else:
		if m < a[i - 1]:
			m = a[i - 1]
		a.append(b[i] + m)
print(' '.join([str(i) for i in a]))


n = int(input())
arr = list(map(int, input().split()))
arr2 = []
maximum = arr[0]
for (i, elem) in enumerate(arr):
	if i == 0:
		arr2.append(arr[i])
	else:
		arr2.append(arr[i] + maximum)
		if arr[i] + maximum > maximum:
			maximum += arr[i]
for elem in arr2:
	print(elem, end=' ')


n = int(input())
b = list(map(int, input().split()))
a = [b[0]]
maxa = b[0]
for i in range(1, len(b)):
	a.append(maxa + b[i])
	if a[-1] > maxa:
		maxa = a[-1]
print(' '.join((str(i) for i in a)))


n = int(input())
b = list(map(int, input().strip().split()))
s = 0
for i in range(n):
	print(s + b[i], end=' ')
	s = max(s + b[i], s)


import sys
input = sys.stdin.readline
n = int(input())
B = list(map(int, input().split()))
X = [0]
A = []
for i in range(n):
	A.append(B[i] + X[i])
	X.append(max(X[-1], A[-1]))
print(' '.join(map(str, A)))


def main():
	from sys import stdin, stdout
	n = int(stdin.readline())
	b = list(map(int, stdin.readline().split()))
	a = [b[0]]
	maxim = b[0]
	for i in range(1, n):
		temp = b[i] + maxim
		a.append(temp)
		maxim = max(maxim, a[-1])
	for i in a:
		stdout.write(str(i) + ' ')
	stdout.write('\n')
main()


n = int(input())
l = list(map(int, input().split()))
print(l[0], end=' ')
suma = 0
for i in range(1, len(l)):
	if l[i - 1] > 0:
		suma += l[i - 1]
	print(l[i] + suma, end=' ')


n = int(input())
List = [int(x) for x in input().split()]
Max = List[0]
A = [List[0]]
for i in range(1, n):
	A.append(List[i] + Max)
	Max = max(Max, List[i] + Max)
print(*A)


n = int(input())
b = str(input()).split(' ')
b = list(map(lambda x: int(x), b))
mx = 0
for i in range(n):
	print(b[i] + mx, end=' ')
	if b[i] + mx > mx:
		mx = b[i] + mx
print('')


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
from collections import defaultdict
from heapq import heappop, heappush, heapify
n = int(input())
l = list(map(int, input().split()))
ans = [l[0]]
maxi = l[0]
for i in range(1, len(l)):
	maxi = max(ans[-1], maxi)
	ans.append(l[i] + maxi)
print(*ans)


import os
import sys
from io import BytesIO, IOBase

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()

def test():
	n = int(input())
	a = list(map(int, input().split()))
	x = 0
	for i in range(n):
		a[i] += x
		x = max(x, a[i])
	print(*a)
test()


length = int(input())
b = list(map(int, input().split()))
x = 0
for i in range(length):
	a = b[i] + x
	print(a, end=' ')
	x = max(a, x)


N = int(input())
B = list(map(int, input().split()))
a = [B[0]]
k = B[0]
for b in B[1:]:
	if b <= 0:
		a.append(k + b)
	else:
		a.append(k + b)
		k += b
print(*a)


def solve(brr, n):
	arr = [brr[0]]
	maxima = brr[0]
	for i in range(1, n):
		arr.append(brr[i] + maxima)
		if arr[i] > maxima:
			maxima = arr[i]
	for i in range(0, n):
		print(arr[i], end=' ')
test = 1
for t in range(0, test):
	n = int(input())
	arr = [int(x) for x in input().split()]
	solve(arr, n)


n = int(input())
b = list(map(int, input().split()))
a = [''] * n
maxim = 0
for i in range(n):
	a[i] = str(maxim + b[i])
	if b[i] > 0:
		maxim += b[i]
print(' '.join(a))


import sys
import math

def ii():
	return sys.stdin.readline().strip()

def idata():
	return [int(x) for x in ii().split()]

def binary_search(array, x):
	(left, right) = (-1, len(array))
	while left + 1 != right:
		middle = (left + right) // 2
		if array[middle] >= x:
			right = middle
		elif array[middle] < x:
			left = middle
	return right

def solve_of_problem():
	n = int(ii())
	data = idata()
	a = [data[0]]
	maxx = data[0]
	for i in range(1, n):
		c = data[i] + maxx
		maxx = max(maxx, c)
		a.append(c)
	for i in range(n):
		a[i] = str(a[i])
	print(' '.join(a))
	return
for ______ in range(1):
	solve_of_problem()


t = int(input())
lista = list(map(int, input().split(' ')))
maximo = 0
r = ''
for p in range(t):
	r += str(lista[p] + maximo) + ' '
	if lista[p] + maximo > maximo:
		maximo = lista[p] + maximo
print(r)


from sys import stdin, stderr

def rl():
	return [int(w) for w in stdin.readline().split()]
(n,) = rl()
b = rl()
x = 0
for bi in b:
	ai = bi + x
	print(bi + x, end=' ')
	if ai > x:
		x = ai
print()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def main():
	t = 1
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		m = 0
		r = []
		for c in a:
			t = m + c
			r.append(t)
			if m < t:
				m = t
		rr.append(JA(r, ' '))
	return JA(rr, '\n')
print(main())


def solve(n, b):
	a = [0] * n
	a[0] = b[0]
	mx = a[0]
	for i in range(1, n):
		a[i] = b[i] + mx
		mx = max(a[i], mx)
	return ' '.join(map(str, a))

def main():
	n = int(input())
	b = [int(i) for i in input().split()]
	print(solve(n, b))
main()


n = int(input())
max = 0
for i in input().split():
	i = int(i)
	print(i + max, end=' ')
	if max < max + i:
		max = max + i


n = int(input())
a = list(map(int, input().split()))
b = []
s = 0
for i in a:
	b.append(s + i)
	if s + i > s:
		s = s + i
print(*b)


n = int(input())
line = input().split()
arr = []
for i in range(n):
	arr.append(int(line[i]))
large = arr[0]
a = [arr[0]]
for i in range(1, n):
	a.append(arr[i] + large)
	if a[i] > large:
		large = a[i]
for i in a:
	print(i, end=' ')


n = int(input())
arr = list(map(int, input().split()))
max = arr[0]
res = []
res.append(arr[0])
for i in range(1, n):
	if max < arr[i] + max:
		max += arr[i]
		res.append(max)
	else:
		res.append(arr[i] + max)
print(*res)


def listint():
	a = input().split()
	for i in range(len(a)):
		a[i] = int(a[i])
	return a

def main(n, b):
	maxi = 0
	ans = []
	for i in range(n):
		if b[i] > 0:
			maxi = b[i] + maxi
			ans.append(maxi)
		else:
			ans.append(maxi + b[i])
	return ans
n = int(input())
b = listint()
ans = main(n, b)
for i in range(n):
	print(ans[i], end=' ')


import sys
import heapq
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]
n = int(data())
b = l()
a = l1d(n)
m = 0
for i in range(n):
	a[i] = m + b[i]
	m = max(m + b[i], m)
print(*a)


dic = [chr(i) for i in range(97, 123)]
n = int(input())
b = [int(j) for j in input().split()]
a = [b[0]]
mx = a[0]
n = n - 1
i = 1
while n != 0:
	mx = max(a[i - 1], mx)
	a.append(b[i] + mx)
	n = n - 1
	i = i + 1
print(*a)


n = int(input())
a = list(map(int, input().split()))
x = 0
for i in range(n):
	a[i] += x
	x = max(x, a[i])
	print(a[i], end=' ')


n = int(input())
B = [int(i) for i in input().split()]
L = [0]
L[0] = B[0]
x = B[0]
for i in range(1, n):
	L.append(B[i] + x)
	x = max(L[i], x)
print(*L)


def solve(arr):
	M = 0
	for x in arr:
		yield (x + M)
		if x > 0:
			M += x
input()
print(*solve(list(map(int, input().split()))))


n = int(input())
b_list = list(map(int, input().split()))
a = []
a.append(b_list[0])
max = b_list[0]
for i in range(n - 1):
	a.append(b_list[i + 1] + max)
	if a[i + 1] > max:
		max = a[i + 1]
print(' '.join(map(str, a)))


n = int(input())
b = list(map(int, input().split()))
b = [-1] + b
a = [-1 for i in range(n + 1)]
m = 0
a[1] = b[1]
m = max(m, a[1])
a[2] = b[2] + a[1]
m = max(m, a[2])
for i in range(3, n + 1):
	a[i] = b[i] + m
	m = max(m, a[i])
for i in range(1, n + 1):
	print(a[i], end=' ')
print()


from collections import Counter, defaultdict, deque
import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	arr = [int(x) for x in input().split()]
	r = 0
	ans = []
	for i in range(n):
		if arr[i] < 0:
			ans.append(r + arr[i])
		else:
			r += arr[i]
			ans.append(r)
	print(*ans)
tt = 1
for test in range(tt):
	solve()


N = int(input())
elem = list(map(int, input().split()))
org = []
org.append(elem[0])
a = elem[0]
for i in range(1, N):
	a = max(a, org[i - 1])
	org.append(elem[i] + a)
for x in org:
	print(x, end=' ')


(how_much, lst, count) = (int(input()), [], 0)
for i in [int(i) for i in input().split()]:
	if count < i + count:
		count = i + count
		print(count, end=' ')
	else:
		print(i + count, end=' ')


from math import *
from copy import *
from sys import *
n = int(input())
b = list(map(int, input().split()))
x = [0] * len(b)
a = [0] * len(b)
a[0] = b[0] + 0
MAX = a[0]
for j in range(1, len(b)):
	x[j] = MAX
	a[j] = x[j] + b[j]
	if a[j] > MAX:
		MAX = a[j]
print(*a)


n = int(input())
a = [int(i) for i in input().split()]
c = 0
z = []
for i in range(n):
	z.append(c + a[i])
	if z[i] > c:
		c = z[i]
print(' '.join(map(str, z)))


import math
import sys
n = int(input())
b = [int(x) for x in input().split()]
a = [0] * n
a[0] = b[0]
mx = a[0]
for i in range(1, n):
	a[i] = b[i] + mx
	mx = max(mx, a[i])
print(*a)


import sys
input = sys.stdin.readline
N = int(input())
B = list(map(int, input().split()))
X = [0]
A = [B[0]]
for (i, b) in enumerate(B):
	if i == 0:
		continue
	X.append(max(X[-1], A[-1]))
	A.append(b + X[-1])
print(*A)


I = input
mx = -1
I()
for i in map(int, I().split()):
	if mx > -1:
		print(mx + i, end=' ')
		mx = max(mx, mx + i)
	else:
		mx = i
		print(i, end=' ')


a = int(input())
b = list(map(int, input().split()))
k = []
s = 0
for i in range(a):
	k.append(b[i] + s)
	if k[i] > s:
		s = k[i]
print(*k)


n = int(input())
ar = [int(x) for x in input().split()]
_sum = ar[0]
r = 0
mx = ar[0]
for i in range(1, len(ar)):
	_sum += ar[i]
	if ar[i] < 0:
		r += ar[i]
		ar[i] += mx
	else:
		ar[i] = _sum - r
		mx = ar[i]
for i in ar:
	print(i, end=' ')


def solve():
	input()
	b = [int(i) for i in input().split()]
	x = [0]
	a = []
	cur = float('-inf')
	for i in range(len(b)):
		a.append(b[i] + x[i])
		cur = max(cur, a[i])
		x.append(cur)
	print(' '.join([str(i) for i in a]))
solve()


n = int(input())
l = list(map(int, input().split()))
x = []
x.append(l[0])
m = l[0]
for i in range(1, n):
	x.append(l[i] + m)
	m = max(x[-1], m)
for i in x:
	print(i, end=' ')
print()


def solve():
	n = input()
	l = list(map(int, input().split()))
	sum = 0
	sum2 = l[0]
	print(l[0], end=' ')
	for i in range(1, len(l)):
		sum = abs(sum2) + l[i]
		print(sum, end=' ')
		if abs(sum) > sum2:
			sum2 = sum
	print('')
solve()


input()
(v, b) = (0, [])
a = [*map(int, input().split())]
for x in a:
	b += [x + v]
	v = max(v, b[-1])
print(*b)


n = int(input())
b = list(map(int, input().split()))
a = [0] * len(b)
mx = 0
for i in range(len(b)):
	a[i] = b[i] + mx
	mx = max(mx, a[i])
print(' '.join(map(str, a)))


n = int(input())
arr = [int(k) for k in input().split()]
mx = 0
ans = []
for i in arr:
	tp = i + mx
	if tp > mx:
		mx = tp
	ans.append(tp)
for s in ans:
	print(s, end=' ')


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
tests = inp()
arr = inlt()
y = arr[0]
i = 1
string = str(y) + ' '
while i < tests:
	string += str(arr[i] + y) + ' '
	if arr[i] > 0:
		y += arr[i]
	i += 1
print(string[:len(string) - 1])


n = int(input())
brr = [int(x) for x in input().split()]
max = 0
for b in brr:
	a = b + max
	print(f'{a} ', end='')
	if a > max:
		max = a
print()


n = int(input())
ln = list(map(int, input().split(' ')))
out = []
out.append(ln[0])
maxsumm = out[0]
for i in range(1, n):
	res = maxsumm + ln[i]
	out.append(res)
	if res >= maxsumm:
		maxsumm = res
print(' '.join(map(str, out)))


n = int(input())
b = [int(x) for x in input().strip().split()]
m = 0
for i in b:
	print(m + i, end=' ')
	m = max(m, m + i)


n = int(input())
b = list(map(int, input().split()))
best = 0
new = []
for i in range(n):
	new.append(b[i] + best)
	if b[i] + best > best:
		best = best + b[i]
print(*new, sep=' ')


n = int(input())
b = list(map(int, input().split()))
mx = 0
a = []
for item in b:
	s = item + mx
	mx = max(mx, s)
	a.append(str(s))
print(' '.join(a))


n = int(input())
a = tuple(map(int, input().split()))
ans = []
maximum = 0
for i in a:
	if i + maximum > maximum:
		i = maximum + i
		maximum = i
	else:
		i = maximum + i
	ans.append(i)
print(' '.join(map(str, ans)))


n = int(input())
b = list(map(int, input().split()))
s = 0
for i in b:
	if i < 0:
		print(s + i, end=' ')
	else:
		s += i
		print(s, end=' ')
print(end='\n')


n1 = int(input())
b = list(map(int, input().split()))
a = []
x = [0]
a.append(b[0] + x[0])
if b[0] > 0:
	d = b[0] + x[0]
else:
	d = x[0]
for i in range(1, n1):
	x.append(d)
	a.append(b[i] + x[i])
	if b[i] > 0:
		d = b[i] + x[i]
	else:
		d = x[i]
print(*a)


n = int(input())
a = input().split(' ')
for i in range(n):
	a[i] = int(a[i])
ans = []
maxans = a[0]
ans.append(a[0])
print(a[0], end=' ')
for i in range(1, n):
	val = maxans + a[i]
	print(val, end=' ')
	if val > maxans:
		maxans = val
	ans.append(val)
print()


n = int(input())
l = list(map(int, input().split()))
s = 0
for i in l:
	p = s + i
	print(p, end=' ')
	if p > s:
		s = p


n = int(input())
L = [int(a) for a in input().split(' ', n - 1)]
a = L[0]
x = max(0, a)
l = []
l.append(a)
for i in range(1, n):
	l.append(L[i] + x)
	if L[i] + x > x:
		x = L[i] + x
print(' '.join(map(str, l)))


from math import sqrt

def factor(n):
	yield 1
	if n % 2 == 0:
		yield 2
	d = int(sqrt(n)) + 3
	for i in range(3, d, 2):
		if n % i == 0:
			yield i

def main():
	c = int(input())
	data = [int(v) for v in input().split()]
	res = [data[0]]
	m = data[0]
	for (i, v) in enumerate(data[1:]):
		res.append(v + m)
		m = max(m, v + m)
	print(' '.join([str(v) for v in res]))
main()


n = int(input())
b = list(map(int, input().split()))
a = [0] * n
x = [0] * n
a[0] = b[0]
x[0] = 0
x[1] = a[0]
maxi = a[0]
for i in range(1, n):
	x[i] = maxi
	a[i] = x[i] + b[i]
	if a[i] > maxi:
		maxi = a[i]
print(*a)


n = int(input())
b = list(map(int, input().split()))[0:n]
a = []
x = []
x.append(0)
for i in range(0, n):
	a.insert(i, b[i] + x[i])
	if x[i] > a[i]:
		x.insert(i + 1, x[i])
	else:
		x.insert(i + 1, a[i])
for i in range(0, n):
	print(a[i], end=' ')


n = int(input())
lst = list(map(int, input().split()))
sum1 = 0
max1 = 0
lst2 = []
for i in range(len(lst)):
	if i == 0:
		lst2.append(lst[i])
		max1 = lst2[i]
	else:
		max1 = max(max1, lst2[i - 1])
		lst2.append(lst[i] + max1)
for i in lst2:
	print(i, end=' ')


n = int(input())
x = list(map(int, input().split()))
y = []
y.append(x[0])
maxim = -999999999999
maxim = max(y[0], maxim)
for i in range(1, n):
	maxim = max(y[i - 1], maxim)
	y.append(maxim + x[i])
print(*y)


from sys import stdin, stdout
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
stdout.write(str(a[0]) + ' ')
maxi = a[0]
for i in range(1, n):
	x = maxi + a[i]
	stdout.write(str(x) + ' ')
	if x > maxi:
		maxi = x


N = int(input())
B = [int(i) for i in input().split(' ')]
B_sz = len(B)
A = [0] * B_sz
A[0] = B[0]
prev_max = A[0]
for i in range(1, B_sz):
	prev_max = max(A[i - 1], prev_max)
	A[i] = B[i] + prev_max
output = ''
for a in A:
	output += str(a)
	output += ' '
print(output)


import sys
from pprint import pprint
if not 'DEBUG' in globals():
	readline = sys.stdin.readline

def read(map_func):
	return map_func(readline().rstrip())

def reads(map_func):
	return list(map(map_func, readline().rstrip().split()))

def readn(map_func, n):
	return [read(map_func) for _ in range(n)]

def readint():
	return read(int)

def readints():
	return reads(int)

def readcol(n):
	return readn(int, n)

def readmat(n):
	return [readints() for _ in range(n)]

def readmap(n):
	return readn(list, n)

def makemat(n, m, v):
	return [[v] * m for _ in range(n)]

def zeromat(n, m=None):
	m = m if m else n
	return makemat(n, m, 0)

def listmat(n, m=None):
	m = m if m else n
	return [[[] for _ in range(m)] for _ in range(n)]

def crosslist(y, x, n=None, m=None):
	return [(p, q) for (p, q) in [(y, x + 1), (y - 1, x), (y, x - 1), (y + 1, x)] if (n == None or 0 <= p < n) and (m == None or 0 <= q < m)]

def roundlist(y, x, n=None, m=None):
	return [(p, q) for (p, q) in [(y, x + 1), (y - 1, x + 1), (y - 1, x), (y - 1, x - 1), (y, x - 1), (y + 1, x - 1), (y + 1, x), (y + 1, x + 1)] if (n == None or 0 <= p < n) and (m == None or 0 <= q < m)]

def plog(obj):
	pprint(obj) if 'DEBUG' in globals() else None

def log(msg, label=None):
	print((label + ': ' if label else '') + str(msg)) if 'DEBUG' in globals() else None

def _logmat(mat, label=None):
	fmt = '{:' + str(max((max((len(str(s)) for s in m)) for m in mat))) + 'd}'
	f = lambda row: '[' + ' '.join((fmt.format(x) for x in row)) + ']'
	[log('[' + f(row), label) if i == 0 else log((' ' * (len(label) + 3) if label else ' ') + f(row) + ']', None) if i == len(mat) - 1 else log((' ' * (len(label) + 3) if label else ' ') + f(row), None) for (i, row) in enumerate(mat)]

def logmat(mat, label=None):
	_logmat(mat, label) if 'DEBUG' in globals() else None
import math
n = readint()
B = readints()
A = [0] * len(B)
x = 0
for i in range(len(B)):
	A[i] = B[i] + x
	x = max(A[i], x)
print(' '.join(map(str, A)))


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	b = list(map(int, input().split()))
	a = [0] * n
	a[0] = b[0]
	m = a[0]
	for i in range(1, n):
		a[i] = b[i] + m
		m = max(m, a[i])
	print(*a)
main()


n = int(input())
b = [int(x) for x in input().split()]
a = []
max = 0
for i in range(len(b)):
	if i == 0:
		a.append(b[i])
	else:
		a.append(b[i] + max)
	if a[i] > max:
		max = a[i]
for i in range(len(a)):
	print(a[i], end=' ')


n = int(input())
l = list(map(int, input().split()))
s = []
mx = 0
for i in l:
	if i >= 0:
		mx += i
		s.append(mx)
	else:
		s.append(mx + i)
print(*s)


n = int(input().strip())
bs = [int(i) for i in input().strip().split()]
ans = [0 for i in range(n)]
ans[0] = bs[0]
cur_max = max(ans[0], 0)
for i in range(1, n):
	ans[i] = bs[i] + cur_max
	if ans[i] > cur_max:
		cur_max = ans[i]
print(' '.join((str(i) for i in ans)))


n = int(input())
b = list(map(int, input().split()))
x = [b[0]]
sum1 = b[0]
for i in range(1, len(b)):
	x.append(sum1 + b[i])
	if b[i] >= 0:
		sum1 += b[i]
print(*x)


n = int(input())
b = list(map(int, input().split()))
cons = 0
a = []
for i in range(len(b)):
	a.append(cons + b[i])
	if b[i] > 0:
		cons += b[i]
print(*a)


import sys
input = sys.stdin.readline
n = int(input())
b = list(map(int, input().split()))
a = [0] * n
x = 0
for i in range(n):
	a[i] = b[i] + x
	x = max(x, a[i])
print(*a)


from sys import stdin, stdout
from os import path
if path.exists('input.txt'):
	stdin = open('input.txt', 'r')
	stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

	def S():
		return stdin.readline().rstrip()

	def Sn():
		return stdin.readline().split(' ')

def func(n, b):
	a = [0] * n
	x = -1
	x = max(x, b[0] - 0)
	a[0] = b[0]
	for i in range(1, n):
		x = max(x, a[i - 1])
		a[i] = x + b[i]
	return a
st = ''
n = I()
l = list(In())
ans = func(n, l)
print(*ans)


from sys import stdin
inf = stdin
n = int(inf.readline())
arr = list(map(int, inf.readline().split(' ')))
ans = [0] * n
ans[0] = arr[0]
x = 0
for i in range(1, n):
	x = max(ans[i - 1], x)
	ans[i] = arr[i] + x
print(*ans)


n = int(input())
l = list(map(int, input().split()))
l1 = []
m = 0
for i in range(n):
	k = l[i] + m
	l1.append(k)
	if k > m:
		m = k
print(*l1)


def solve(b):
	a = [0] * len(b)
	a[0] = b[0] + 0
	a[1] = b[1] + a[0]
	maks = max(a[1], a[0])
	for i in range(2, len(b)):
		maks = max(maks, a[i - 1])
		a[i] = b[i] + maks
	return ' '.join(map(str, a))
input()
print(solve(list(map(int, input().split(' ')))))


N = int(input())
b = list(map(int, input().split()))
largest = 0
for i in range(N):
	temp = b[i]
	b[i] += largest
	if temp > 0:
		largest += temp
for i in b:
	print(i, end=' ')


l = int(input())
i = list(map(int, input().split()))
x = 0
a = []
for index in range(l):
	a.append(i[index] + x)
	x = max(x, a[index])
print(*a)


n = int(input())
A = list(map(int, input().split()))
ans = [0] * n
m = 0
for i in range(n):
	ans[i] = m + A[i]
	m = max(m, ans[i])
print(*ans)


n = int(input())
br = list(map(int, input().split()))
ar = [0] * n
ar[0] = br[0]
ma = ar[0]
for i in range(1, n):
	ar[i] = br[i] + ma
	ma = max(ma, ar[i])
print(*ar)


n = int(input())
b_array = [0]
a_array = [0] * (n + 1)
x_array = [0] * (n + 1)
b_array += [int(x) for x in input().split()]
a_array[1] = b_array[1]
x_array[1] = 0
for i in range(2, n + 1):
	x_array[i] = max(a_array[i - 1], x_array[i - 1])
	a_array[i] = b_array[i] + x_array[i]
for x in a_array[1:]:
	print(x, end=' ')


def solve(n, b):
	a = [None] * n
	a[0] = b[0]
	curr_x = max(0, a[0])
	for i in range(1, n):
		a_i = b[i] + curr_x
		a[i] = a_i
		curr_x = max(curr_x, a_i)
	return ' '.join((str(a_i) for a_i in a))
n = int(input())
b = [int(x) for x in input().split()]
print(solve(n, b))


n = int(input())
a = [0] + list(map(int, input().split()))
ma = a[0]
ans = []
for i in range(1, n + 1):
	k = ma + a[i]
	ans.append(k)
	ma = max(ma, k)
print(*ans)


n = int(input())
a = [int(i) for i in input().split()]
print(a[0], end=' ')
t = a[0]
for i in a[1:]:
	if i < 0:
		print(t + i, end=' ')
	else:
		t += i
		print(t, end=' ')
print()


a = int(input())
l = list(map(int, input().split()))
x = []
a = []
x.append(0)
a.append(x[0] + l[0])
max = 0
while len(a) != len(l):
	if a[len(a) - 1] > max:
		max = a[len(a) - 1]
	x.append(max)
	a.append(max + l[len(a)])
for i in a:
	print(i, end=' ')


n = int(input())
arr = list(map(int, input().split()))
arr2 = [0]
maximum = 0
for i in range(n):
	arr2.append(arr[i] + maximum)
	if arr2[i + 1] > maximum:
		maximum = arr2[i + 1]
print(*arr2[1:])


import math
n = int(input())
data = input().split()
b = []
for i in data:
	b.append(int(i))
a = [b[0]]
maxx = 0
for i in range(len(b) - 1):
	if b[i] >= 0:
		maxx = a[i]
	a.append(b[i + 1] + maxx)
for i in a:
	print(i, end=' ')


import sys

def main():

	def GCD(x, y):
		while y:
			(x, y) = (y, x % y)
		return x

	def lcm(a, b):
		return a * b // GCD(a, b)

	def merge(a, start, mid, end, d):
		p = start
		q = mid + 1
		arr = [0] * (end - start + 1)
		k = 0
		coun = 0
		for i in range(start, end + 1):
			if p > mid:
				arr[k] = a[q]
				q += 1
				k += 1
			elif q > end:
				arr[k] = a[p]
				d[a[p]] += coun
				k += 1
				p += 1
			elif a[p] < a[q]:
				arr[k] = a[p]
				d[a[p]] += coun
				k += 1
				p += 1
			else:
				arr[k] = a[q]
				k += 1
				q += 1
				coun += 1
		for i in range(k):
			a[start] = arr[i]
			start += 1

	def mergesort(a, start, end, d):
		if start < end:
			mid = (start + end) // 2
			mergesort(a, start, mid, d)
			mergesort(a, mid + 1, end, d)
			merge(a, start, mid, end, d)

	def inversion(l):
		d = {}
		for i in l:
			d[i] = 0
		mergesort(l, 0, len(l) - 1, d)
		return d

	def binary_search_lower(A, low, high, k):
		if high - low != 1:
			mid = (low + high) // 2
			x = A[mid]
			if x >= k:
				return binary_search_lower(A, low, mid, k)
			else:
				return binary_search_lower(A, mid, high, k)
		if A[low] >= k:
			return low
		else:
			return high

	def binary_expo(x, n):
		if n == 0:
			return 1
		elif n % 2 == 0:
			return binary_expo(x * x, n // 2)
		else:
			return x * binary_expo(x * x, (n - 1) // 2)

	def modu_expo(x, n, m):
		if n == 0:
			return 1
		elif n % 2 == 0:
			return modu_expo(x * x % m, n // 2, m)
		else:
			return x * modu_expo(x * x % m, (n - 1) // 2, m) % m

	def eEuclid(c, m):
		if m == 0:
			global d
			global x
			global y
			d = c
			x = 1
			y = 0
		else:
			eEuclid(m, c % m)
			temp = x
			x = y
			y = temp - c // m * y

	def mod_Inv(c, m):
		eEuclid(c, m)
		return (x % m + m) % m

	def ncr(n, r, p):
		num = den = 1
		for i in range(r):
			num = num * (n - i) % p
			den = den * (i + 1) % p
		return num * pow(den, p - 2, p) % p
	n = int(sys.stdin.readline())
	l = [int(y) for y in sys.stdin.readline().split()]
	m = l[0]
	print(m, end=' ')
	for i in range(1, n):
		print(m + l[i], end=' ')
		if m + l[i] > m:
			m = m + l[i]
	print()
main()


n = int(input())
arr = list(map(int, input().split()))
maximum = 0
for elem in arr:
	print(elem + maximum, end=' ')
	if elem + maximum > maximum:
		maximum += elem


N = int(input())
B = [int(_) for _ in input().split()]
cm = 0
A = []
for el in B:
	A.append(cm + el)
	cm = max(cm, cm + el)
print(' '.join(map(str, A)))


a = int(input())
b = list(map(int, input().split()))
l = []
x = 0
for i in range(a):
	y = b[i] + x
	l.append(y)
	x = max(y, x)
print(*l)


n = int(input())
x = list(map(int, input().split()))
op = [x[0]]
c = max(0, x[0])
for i in x[1:]:
	op.append(c + i)
	c = max(c, op[-1])
print(*op)


n = int(input())
mas = list(map(int, input().split()))
maxi = 0
for i in range(n):
	print(maxi + mas[i], end=' ')
	maxi = max(maxi, maxi + mas[i])
print()


n = int(input())
b = [0] + list(map(int, input().split()))

def f(a, c):
	return a if a > c else c
a = b[1]
print(a, end=' ')
for i in range(2, n + 1):
	a = b[i] + f(a - b[i - 1], a)
	print(a, end=' ')


n = int(input())
b = list(map(int, input().split()))
arr = [b[0]]
m_arr = b[0]
for i in range(1, n):
	arr.append(m_arr + b[i])
	m_arr = max(m_arr, arr[-1])
print(*arr)


n = int(input())
b = list(map(int, input().split()))
a = [b[0]]
x = [0, b[0]]
for i in range(1, n):
	a.append(b[i] + x[i])
	if a[i] > x[i]:
		x.append(a[i])
	else:
		x.append(x[i])
print(' '.join([str(i) for i in a]))


n = int(input())
l = list(map(int, input().split()))
sum = 0
for i in range(1, n):
	if sum < l[i - 1]:
		sum = l[i - 1]
	l[i] += sum
print(*l)


def main():
	n = int(input())
	b = list(map(int, input().split()))
	m = 0
	for i in range(0, n):
		a = b[i] + m
		print(a, end=' ')
		if a > m:
			m = a
	print()
main()


def answer(b, p):
	a = [0 for i in range(p)]
	a[0] = b[0]
	a[1] = b[1] + a[0]
	q = [0 for i in range(p)]
	q[0] = str(a[0])
	q[1] = str(a[1])
	maxx = [0 for i in range(p)]
	maxx[1] = a[0]
	for i in range(2, p):
		maxx[i] = max(maxx[i - 1], a[i - 1])
		a[i] = b[i] + maxx[i]
		q[i] = str(a[i])
	return q
p = int(input())
s = input()
s = s.split()
b = []
for i in s:
	b.append(int(i))
a = answer(b, p)
z = ' '.join(a)
print(z)


import sys
import math
n = int(input())
b = list(map(int, input().split(' ')))
ans = []
mx = b[0]
ans.append(b[0])
for i in range(1, n):
	ans.append(mx + b[i])
	mx = max(mx, mx + b[i])
for i in range(0, len(ans)):
	print(ans[i], sep=' ', end=' ')


n = int(input())
b = list(map(int, input().split()))
a = [None for i in range(n)]
a[0] = b[0]
mx = 0
for i in range(1, n):
	mx = max(mx, a[i - 1])
	a[i] = b[i] + mx
for i in a:
	print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
d = 0
for i in range(0, n):
	print(a[i] + d, end=' ')
	if a[i] > 0:
		d += a[i]
print('')


n = int(input())
b = list(map(int, input().split()))
y = []
x = []
for i in range(n):
	if i == 0:
		x.append(0 + b[0])
	elif i == 1:
		x.append(x[0] + b[i])
	else:
		if x[i - 1] > x[i - 2]:
			c = x[i - 1]
		else:
			c = x[i - 2]
		if i >= 3:
			if d > c:
				c = d
		d = c
		x.append(b[i] + c)
for i in range(n):
	print(x[i], end=' ')


n = int(input())
A = map(int, input().split())
B = list(A)
res = []
res.append(B[0])
res.append(B[0] + B[1])
k = 2
m = max(res)
while k < n:
	res.append(m + B[k])
	if m + B[k] > m:
		m = m + B[k]
	k += 1
for i in res:
	print(i, end=' ')


from sys import stdout, stdin
(_input, _print) = (stdin.buffer.readline, stdout.write)
(_range, _int) = (range, int)

def solution():
	n = _int(_input())
	arr = [_int(i) for i in _input().split()]
	old = 0
	ans = []
	for i in _range(n):
		ans.append(arr[i] + old)
		old = ans[i] if old < ans[i] else old
	print(*ans)
solution()


n = int(input())
b = list(map(int, input().split()))
x = [0]
a = []
for i in range(n):
	if i == 0:
		a.append(b[i])
		c = max(a)
		x.append(c)
	else:
		k = b[i] + x[i]
		a.append(k)
		if c <= k:
			x.append(k)
			c = k
		else:
			x.append(c)
print(*a, sep=' ')


n = int(input())
b = list(map(int, input().split()))
solution = [0] * n
x = 0
for i in range(n):
	solution[i] = b[i] + x
	if solution[i] > x:
		x = solution[i]
print(' '.join(map(str, solution)))


n = int(input())
num = list(map(int, input().split()))
a = [num[0]]
maxi = a[0]
for i in range(1, n):
	a.append(num[i] + maxi)
	maxi = max(num[i] + maxi, maxi)
for i in a:
	print(i, end=' ')


n = int(input())
b = list(map(int, input().split()))
max = 0
for i in range(n):
	ai = b[i] + max
	if ai > max:
		max = ai
	print(ai, end=' ')


def main():
	n = int(input())
	b = list(map(int, input().split()))
	maximum = b[0]
	a = [b[0]]
	for i in b[1:]:
		a.append(i + maximum)
		maximum = max(maximum, i + maximum)
	print(*a)
main()


n = int(input())
b = list(map(int, input().split()))
l = 0
for i in range(0, n):
	if i == 0:
		print(b[0], end=' ')
		if b[0] > l:
			l = b[0]
	else:
		print(b[i] + l, end=' ')
		if b[i] + l >= l:
			l = b[i] + l


a = int(input())
b = list(map(int, input().split()))
x = []
r = 0
for i in range(len(b)):
	s = b[i] + r
	x.append(s)
	r = max(r, s)
print(*x)


n = int(input())
B = list(map(int, input().split(' ')))
A = []
A.append(B[0])
m = max(0, A[0])
for i in range(1, n):
	if A[i - 1] > m:
		m = A[i - 1]
	A.append(m + B[i])
s = ''
for i in A:
	s += str(i) + ' '
print(s)


b_len = int(input())
b = [int(i) for i in input().split(' ')]
a1 = 0 + b[0]
a = [a1]
m = 0
for i in range(1, b_len):
	current_x = a[-1] if a[-1] >= m else m
	m = current_x
	a.append(b[i] + current_x)
print(' '.join([str(j) for j in a]))


input()
a = [int(a) for a in input().split()]
b = list()
r = 0
while r < len(a):
	if r == 0:
		c = 1
		m = a[0]
		b.append(a[0])
	elif r != 0 and a[r - 1] < 0:
		c = c + 1
		m = a[r] + b[r - c]
		b.append(m)
	else:
		c = 1
		m = a[r] + b[r - 1]
		b.append(m)
	print(m, end=' ')
	r = r + 1


import math
n = int(input())
l = [int(x) for x in input().split()]
ans = [l[0]]
mx = l[0]
for j in range(1, n):
	ans.append(mx + l[j])
	mx = max(ans[-1], mx)
print(*ans)


n = int(input())
l = list(map(int, input().split()))
maxi = l[0]
ans = [0] * n
ans[0] = l[0]
for i in range(1, n):
	ans[i] = maxi + l[i]
	maxi = max(maxi, ans[i])
for i in ans:
	print(i, end=' ')
print()


def main():
	input()
	arr = list(map(int, input().split()))
	max = 0
	for i in arr:
		val = i + max
		max = max if max > val else val
		print(val, end=' ')
main()


import collections

def solve(n, arr):
	ans = []
	x = 0
	for i in range(n):
		ans.append(arr[i] + x)
		x = max(x, ans[-1])
	return ' '.join(map(str, ans))
n = int(input().strip())
arr = list(map(int, input().strip().split()))
print(solve(n, arr))


a = int(input())
arr = list(map(int, input().split()))
ans = []
smax = 0
for i in arr:
	ans.append(smax + i)
	if i > 0:
		smax = smax + i
print(' '.join(map(str, ans)))


N = int(input())
b = list(map(int, input().split()))
a = [0] * N
a[0] = b[0]
maxs = max(0, a[0])
for i in range(1, N):
	current_max = max(maxs, a[i - 1])
	a[i] = b[i] + current_max
	maxs = current_max
for j in a:
	print(j, end=' ')


n = int(input())
b = [int(x) for x in input().split()]
c = 0
ans = []
for i in range(len(b)):
	b[i] += c
	c = max(c, b[i])
	ans.append(str(b[i]))
print(' '.join(ans))


num = int(input())
nums = list(map(int, input().split()))
x = 0
output = ''
a_max = -100000000000
for i in range(len(nums)):
	a = nums[i] + x
	output += str(a) + ' '
	if a > a_max:
		x = a
		a_max = a
print(output)


n = int(input())
l = []
l = [int(x) for x in input().split()]
sum = 0
for x in l:
	if x < 0:
		print(sum + x, end=' ')
	else:
		sum += x
		print(sum, end=' ')


import sys
input = sys.stdin.buffer.readline
n = int(input())
arr = list(map(int, input().split()))
x = 0
for y in arr:
	print(y + x, end=' ')
	if x < y + x:
		x = y + x


n = int(input())
b = [int(i) for i in input().split()]
a = []
m = 0
for i in range(n):
	v = b[i] + m
	m = max(m, v)
	a.append(v)
print(' '.join([str(i) for i in a]))


n = int(input())
ls = list(map(int, input().split()))
msf = 0
res = []
for e in ls:
	v = msf + e
	msf = max(msf, v)
	res.append(v)
for e in res:
	print(e, end=' ')


n = int(input())
xs = [int(x) for x in input().split()]
ans = []
pmax = 0
for x in xs:
	ans.append(x + pmax)
	pmax = max(ans[-1], pmax)
print(' '.join((str(x) for x in ans)))


n = int(input())
b = [0] + list(map(int, input().split()))
a = [0, str(b[1])]
for i in range(2, n + 1):
	a.append(str(int(b[i]) + max(int(a[i - 1]) - int(b[i - 1]), int(a[i - 1]))))
print(' '.join(a[1:]))


t = 1
for _ in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	large = 0
	a = []
	for i in range(n):
		a.append(b[i] + large)
		large = max(large, a[-1])
	for i in range(n):
		print(a[i], end=' ')
	print()


n = int(input())
b = list(map(int, input().split()))
mx = 0
a = [0] * n
for i in range(n):
	num = b[i] + mx
	a[i] = num
	if num > mx:
		mx = num
	print(num, end=' ')


n = int(input().strip())
blis = list(map(int, input().strip().split()))
maxele = blis[0]
alis = [blis[0]] * n
for ind in range(1, n):
	alis[ind] = maxele + blis[ind]
	maxele = max(maxele, alis[ind])
for ele in alis:
	print(ele, end=' ')


n = int(input())
arr = list(map(int, input().split()))
maxx = 0
res = []
for x in range(n):
	res.append(maxx + arr[x])
	maxx = max(maxx, res[x])
print(*res)


import sys, math
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
t = 1
for tt in range(t):
	n = inp()
	b = inlt()
	a = [b[0], b[1] + b[0]]
	q = max(a[0], a[1])
	for i in range(2, len(b)):
		a.append(b[i] + q)
		q = max(q, a[-1])
	print(*a)


import math
import sys
import itertools
import fractions
wtf = sys.stdin.read()
wtf = wtf.strip().split('\n')
n = int(wtf[0])
B = list(map(int, wtf[1].split()))
A = [B[0]]
M = A[0]
for i in range(1, n):
	if A[i - 1] > M:
		M = A[i - 1]
	A.append(B[i] + M)
print(' '.join(map(str, A)))


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def get_str():
	return input().decode().strip()

def rint():
	return map(int, input().split())

def oint():
	return int(input())
n = oint()
b = list(rint())
a = []
x = 0
for i in range(n):
	a.append(b[i] + x)
	x = max(x, a[i])
print(*a)


n = int(input())
b = list(map(int, input().split()))
cmax = b[0]
res = []
res.append(cmax)
for i in range(1, n):
	if b[i] >= 0:
		res.append(cmax + b[i])
		cmax = max(cmax, cmax + b[i])
	else:
		res.append(cmax + b[i])
for i in res:
	print(i, end=' ')


n = int(input())
l = list(map(int, input().split()))
a = [0]
max = a[0]
for i in range(0, n):
	k = l[i] + max
	if k > max:
		max = k
	a.append(k)
	print(k, end=' ')


from sys import stdin, stdout
n = int(stdin.readline())
array = list(map(int, stdin.readline().split(' ')))
m = 0
for i in range(len(array)):
	num = m + array[i]
	stdout.write(str(num))
	if i < len(array) - 1:
		stdout.write(' ')
	m = max(m, num)


n = int(input())
b = list(map(int, input().split()))
max = 0
a = list()
for i in b:
	t = i + max
	a.append(t)
	if max < i + max:
		max = t
for i in a:
	print(i, end=' ')


n = int(input())
l = list(map(int, input().split()))
m = l[0]
ans = [l[0]]
for i in l[1:]:
	if ans[-1] > m:
		m = ans[-1]
	ans.append(m + i)
for i in ans:
	print(i, end=' ')


n = int(input())
arr = [int(x) for x in input().strip().split()]
mx = 0
res = []
s = 0
for a in arr:
	s = mx + a
	res.append(s)
	mx = max(mx, res[-1])
print(*res)


k = int(input())
a = list(map(int, input().split()))
b = 0
for i in a:
	print(b + i, end=' ')
	b += max(0, i)


n = int(input())
b = list(map(int, input().split()))
a = [0] * n
c = 0
for i in range(len(b)):
	a[i] = b[i] + c
	c = max(c, b[i], a[i])
print(*a)


n = int(input())
b = list(map(int, input().split()))
a = [None for _ in range(n)]
a[0] = b[0]
a[1] = a[0] + b[1]
x = [None for _ in range(n)]
x[0] = 0
x[1] = a[0]
for i in range(2, n):
	x[i] = max(a[i - 1], x[i - 1])
	a[i] = x[i] + b[i]
print(*a)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
li = inlt()
a = []
x = 0
for i in range(n):
	y = li[i] + x
	x = max(y, x)
	print(y, end=' ')


t = int(input())
l = list(map(int, input().split()))
x = 0
for i in l:
	a = x + i
	print(a, end=' ')
	x = max(x, a)


n = int(input())
b = list(map(int, input().split()))
l = []
l.append(b[0])
c = l[0]
for i in range(1, len(b)):
	if b[i] >= 0:
		c = c + b[i]
		l.append(c)
	else:
		l.append(c + b[i])
for i in l:
	print(i, end=' ')


input()
b = list(map(int, input().split()))
a = []
m = 0
for bx in b:
	ax = bx + m
	m = max(m, ax)
	a.append(ax)
print(' '.join(map(str, a)))


n = int(input())
b = list(map(int, input().split()))
m = [0]
a = []
for i in range(n):
	a.append(b[i] + m[i])
	m.append(max(m[i], a[i]))
print(*a, sep=' ')


n = int(input())
l = list(map(int, input().split(' ')))
a = [l[0]]
maxi = l[0]
for i in range(1, len(l)):
	a.append(l[i] + maxi)
	if a[i] > maxi:
		maxi = a[i]
for i in a:
	print(i, end=' ')


MOD = 10 ** 9 + 7
INT_MAX = 10 ** 20 + 7

def INPUT():
	return list((int(i) for i in input().split()))

def LIST_1D_ARRAY(n):
	return [0 for _ in range(n)]

def LIST_2D_ARRAY(m, n):
	return [[0 for _ in range(n)] for _ in range(m)]

def power(a, x):
	res = 1
	while x > 0:
		if x & 1:
			res = res * a % MOD
		a = a * a % MOD
		x //= 2
	return res % MOD

def NCR_MOD(n, r):
	num = 1
	for i in range(n, n - r, -1):
		num = num * i % MOD
	for j in range(1, r + 1):
		num = num * power(j, MOD - 2) % MOD
	return num
import math as M

def calc(B):
	n = len(B)
	A = [0] * n
	A[0] = B[0]
	tillmax = max(0, A[0])
	for i in range(1, n):
		A[i] = tillmax + B[i]
		tillmax = max(0, tillmax, A[i])
	return A
n = int(input())
A = INPUT()
print(*calc(A))


import sys

class BMaximums:

	def solve(self):
		n = int(input())
		b = [int(_) for _ in input().split()]
		a = b[:]
		a[0] = b[0]
		pre_max = a[0]
		for i in range(1, n):
			a[i] = b[i] + pre_max
			pre_max = max(pre_max, a[i])
		print(*a)
solver = BMaximums()
input = sys.stdin.readline
solver.solve()


a = int(input())
b = list(map(int, input().split(' ')))
c = []
c.append(b[0])
print(c[0], end=' ')
f = c[0]
c.append(c[0] + b[1])
e = c[1]
print(c[1], end=' ')
for i in range(2, a):
	if e >= f:
		d = e + b[i]
		print(d, end=' ')
		f = d
	else:
		d = f + b[i]
		print(d, end=' ')
		e = d


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
n = inputnum()
b = inputlist()
a = []
mx = 0
for i in range(n):
	a.append(b[i] + mx)
	mx = max(mx, b[i] + mx)
print(*a)


from sys import stdin, stdout

def main():
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	x = 0
	a = []
	for y in arr:
		new_one = y + x
		a.append(new_one)
		if new_one > x:
			x = new_one
	stdout.write(' '.join([str(x) for x in a]))
main()


n = int(input())
arr = list(map(int, input().split()))
maxCurr = arr[0]
ans = [maxCurr]
for i in range(1, n):
	a = arr[i] + maxCurr
	ans.append(a)
	maxCurr = max(maxCurr, a)
print(*ans)


n = int(input())
B = list(map(int, input().split()))
A = list()
X = list()
for i in range(0, len(B)):
	if i == 0:
		A.append(B[i])
		X.append(0)
		continue
	else:
		X.append(max(X[i - 1], A[i - 1]))
		A.append(B[i] + X[i])
print(*A, sep=' ')


import math

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	n = Read.int()
	b = Read.list_int()
	m = 0
	a = []
	for i in b:
		r = m + i
		if r > m:
			m = r
		a.append(str(r))
	print(' '.join(a))
query_count = 1
while query_count:
	query_count -= 1
	solve()


import sys
input = lambda : sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
s = 0
for i in range(n):
	print(s + a[i], end=' ')
	s += max(a[i], 0)


n = int(input())
b = []
c = 0
a = []
b = list(map(int, input().split()))
a.append(b[0])
x = 0
for j in range(1, n):
	x = max(x, a[j - 1])
	a.append(b[j] + x)
for k in range(n):
	print(a[k], end=' ')


n = int(input())
b = list(map(lambda x: int(x), input().split()))
ans = [b[0]]
x = b[0]
for i in range(1, n):
	ans.append(b[i] + x)
	x = max(x, ans[-1])
print(' '.join((str(x) for x in ans)))


n = int(input())
b = list(map(int, input().split()))
su = b[0]
maxi = b[0]
a = b[0]
print(b[0], end=' ')
for i in range(1, n):
	maxi = max(su, a, maxi)
	a = b[i] + maxi
	print(a, end=' ')
	su += b[i]


import os
import sys
from io import BytesIO, IOBase

def solution(n, brr):
	xx = 0
	for i in range(n):
		brr[i] += xx
		xx = max(xx, brr[i])
		print(brr[i], end=' ')

def main():
	n = r_int()
	brr = r_array()
	solution(n, brr)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())

def w_array(arr):
	for x in arr:
		write(x, end=' ')
	write()
main()


n = int(input())
b = list(map(int, input().split()))
a = []
c = 0
for i in range(n):
	if b[i] < 0:
		s = c + b[i]
		a += [s]
	else:
		s = c + b[i]
		a += [s]
		c = s
print(' '.join(map(str, a)))


t = int(input())
n = [int(i) for i in input().split()]
a = []
p = n[0]
a.append(p)
for i in range(1, t):
	p1 = p + n[i]
	if p1 > p:
		p = p1
	a.append(p1)
for i in a:
	print(i, end=' ')


l = int(input())
b = [int(i) for i in input().split()]
a = [b[0]]
m = a[0]
for i in range(1, len(b)):
	an = b[i] + m
	m = max(m, an)
	a.append(an)
print(' '.join([str(i) for i in a]))


n = int(input())
dum = str(input())
dum1 = dum.split()
b = []
for i in dum1:
	i = int(i)
	b.append(i)
a = [b[0]]
z = b[0]
y = len(b) - 1
n = 1
while y > 0:
	dum = 0
	dum = b[n] + z
	if dum > z:
		z = dum
	y -= 1
	n += 1
	a.append(dum)
for i in a:
	i = int(i)
	print(i, end=' ')


n = int(input())
b = [int(z) for z in input().split()]
a = [0] * n
x = 0
for i in range(len(b)):
	a[i] = b[i] + x
	x = max(a[i], x)
print(*a)


import math
n = int(input())
arr = list(map(int, input().split()))
max_here = arr[0]
B = []
B.append(arr[0])
for i in range(1, n):
	if arr[i] > 0:
		max_here += arr[i]
		B.append(max_here)
	else:
		B.append(max_here + arr[i])
print(*B)


def I():
	return list(map(int, input().split()))
n = int(input())
b = I()
a = [b[0]]
m = a[0]
for i in range(1, n):
	a.append(m + b[i])
	m = max(a[i], m)
print(*a)


n = int(input())
l = list(map(int, input().split()))
m = l[0]
print(m, end=' ')
for i in range(1, n):
	if m + l[i] >= m:
		m = m + l[i]
	else:
		print(m + l[i], end=' ')
		continue
	print(m, end=' ')


n = int(input())
l1 = [int(x) for x in input().split()]
l = []
l.append(l1[0])
m = l[0]
for j in range(1, n):
	if l1[j] > 0:
		m = m + l1[j]
		l.append(m)
	else:
		l.append(m + l1[j])
print(*l)


n = int(input())
nums = [int(i) for i in input().split(' ')]
i = 1
ans = [0] * n
max_ = 0
ans[0] = nums[0]
max_ = max(ans[0], 0)
while i < len(nums):
	ans[i] = nums[i] + max_
	if ans[i] > max_:
		max_ = ans[i]
	i += 1
for i in ans:
	print(i, end=' ')


tc = 1
import math
while tc:
	tc -= 1
	n = int(input())
	ls = list(map(int, input().split()))
	op = []
	m = 0
	for item in ls:
		op.append(item + m)
		if m < op[-1]:
			m = op[-1]
	print(*op)


n = int(input())
b = list(map(int, input().split()))
a = [0] * len(b)
for i in range(n):
	if i == 0:
		max__ = 0
		a[0] = b[0] + max__
	else:
		max__ = max(max__, a[i - 1])
		a[i] = b[i] + max__
print(*a)


n = int(input())
b = list(map(int, input().split()))
a = [0] * n
ma = 0
for i in range(n):
	a[i] = ma + b[i]
	ma = max(a[i], ma)
print(*a)


n = int(input())
a = []
mx = 0
for bb in map(int, input().split()):
	a.append(bb + mx)
	mx = max(mx, a[-1])
print(' '.join([str(aa) for aa in a]))


n = int(input())
b = list(map(int, input().split(' ')))
a = [0] * n
m = 0
for i in range(n):
	a[i] = b[i] + m
	m = max(m, a[i])
print(' '.join((str(x) for x in a)))


n = int(input())
b = list(map(int, input().split()))
c = 0
for i in b:
	r = c + i
	c = max(r, c)
	print(r, end=' ')
print()


from sys import stdin
n = int(stdin.readline())
B = list(map(int, stdin.readline().split()))
A = [0 for i in range(n)]
A[0] = B[0]
A[1] = B[1] + A[0]
max_value = max(A[0], A[1])
for i in range(2, n):
	A[i] = B[i] + max_value
	max_value = max(max_value, A[i])
for item in A:
	print(item, end=' ')
print('')


n = int(input())
b = list(map(int, input().split()))
print(b[0], end=' ')
ma = b[0]
for i in b[1:]:
	print(ma + i, end=' ')
	if ma < ma + i:
		ma = ma + i


from sys import exit

def i():
	return input()

def ii():
	return int(input())

def iis():
	return map(int, input().split())

def liis():
	return list(map(int, input().split()))

def print_array(a):
	print(' '.join(map(str, a)))
n = ii()
b = liis()
maxi = [0]
a = [b[0]]
maxi_a = a[0]
for i in range(len(b) - 1):
	maxi_a = max(maxi_a, a[i])
	maxi.append(maxi_a)
	a.append(b[i + 1] + maxi[i + 1])
print_array(a)


n = int(input())
b = input().split()
b = list(map(int, b))
sum = 0
for i in range(n):
	b[i] = b[i] + sum
	sum = max(b[i], sum)
print(' '.join(map(str, b)))


size = int(input())
b_list = [int(a) for a in input().split(' ')]
a_list = []
x_list = [0]
a_list.append(b_list[0] + x_list[0])
for i in range(0, size - 1):
	x_list.append(max(a_list[i], x_list[i]))
	a_list.append(b_list[i + 1] + x_list[i + 1])
print(' '.join([str(a) for a in a_list]))


def solve(n):
	a = list()
	bq = ''
	f = 0
	a = input().split()
	for i in a:
		if int(i) >= 0:
			f = int(i) + f
			bq += str(f)
			bq += ' '
		else:
			a = int(i) + f
			bq += str(a)
			bq += ' '
	print(bq)
solve(int(input()))


import sys
read = sys.stdin.buffer.readline
for _ in range(1):
	n = int(read())
	b = list(map(int, input().split()))
	(le, mx) = (0, 0)
	for el in b:
		mx = max(mx, le)
		print(el + mx, end=' ')
		le = mx + el


def maxi(a, b):
	if a > b:
		return a
	else:
		return b
aux = 0
n = int(input())
b = list(map(int, input().split()))
for i in range(0, n - 1):
	aux = maxi(aux, b[i])
	b[i + 1] = b[i + 1] + aux
print(*b)


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict
import bisect
import heapq as hq

def main():
	try:
		n = int(input())
		l = list(map(int, input().split()))
		i = 0
		t = []
		for x in l:
			if x >= 0:
				i += x
				t.append(i)
			else:
				t.append(i - abs(x))
		print(*t)
	except:
		pass
M = 998244353
P = 1000000007
main()


n = int(input())
nums = list(map(int, input().split()))
ans = []
maxx = nums[0]
ans.append(maxx)
for i in nums[1:]:
	ans.append(maxx + i)
	maxx = max(maxx + i, maxx)
print(*ans)


t = int(input())
b = [int(x) for x in input().split()]
a = []
aElement = 0
for i in b:
	a.append(aElement + i)
	if i > 0:
		aElement += i
print(*a)


t = int(input())
s = list(map(int, input().split()))
positive = 0
negative = 0
d = []
for j in s:
	if j >= 0:
		positive += j
		d.append(positive)
	elif j < 0:
		negative = positive + j
		d.append(negative)
print(*d)


from sys import stdin
from bisect import bisect_left as bl
from bisect import bisect_right as br

def input():
	return stdin.readline()[:-1]

def intput():
	return int(input())

def sinput():
	return input().split()

def intsput():
	return map(int, sinput())

class RangedList:

	def __init__(self, start, stop, val=0):
		self.shift = 0 - start
		self.start = start
		self.stop = stop
		self.list = [val] * (stop - start)

	def __setitem__(self, key, value):
		self.list[key + self.shift] = value

	def __getitem__(self, key):
		return self.list[key + self.shift]

	def __repr__(self):
		return str(self.list)

	def __iter__(self):
		return iter(self.list)

def dprint(*args, **kwargs):
	if debugging:
		print(*args, **kwargs)
debugging = 1
n = intput()
b = list(intsput())
a = [b[0]]
largest = b[0]
for i in range(1, n):
	x = b[i]
	a.append(largest + x)
	largest = max(largest, largest + x)
print(*a)


n = int(input())
ls = list(map(int, input().split()))
res = [ls[0]]
s = ls[0]
for i in range(1, n):
	res.append(s + ls[i])
	if res[-1] > s:
		s = res[-1]
print(*res)


n = int(input())
l = [int(x) for x in input().split()]
(v, b) = (0, [])
for x in l:
	b += [x + v]
	v = max(v, b[-1])
print(*b)


n = int(input())
l = list(map(int, input().split()))
z = val = 0
for i in range(0, len(l)):
	l[i] = l[i] + val
	val = max(val, l[i])
for i in l:
	print(i, end=' ')


n = int(input())
b = [int(x) for x in input().split()]
a = [0 for _ in range(n)]
a[0] = b[0]
cur_max = a[0]
for i in range(1, n):
	a[i] = b[i] + cur_max
	if a[i] > cur_max:
		cur_max = a[i]
print(' '.join((str(x) for x in a)))


n = int(input())
l = list(map(int, input().split()))
s = 0
d = []
for i in range(n):
	if l[i] >= 0:
		s = s + l[i]
		d.append(s)
	else:
		d.append(s + l[i])
print(*d)


n = int(input())
lst = [int(i) for i in input().split()]
mx = 0
for i in range(n):
	lst[i] += mx
	mx = max(mx, lst[i])
print(*lst)


n = int(input())
B = list(map(int, input().split()))
A = []
maxim = B[0]
A.append(B[0])
for i in range(1, n):
	A.append(maxim + B[i])
	if A[i] > maxim:
		maxim = A[i]
A = list(map(str, A))
print(' '.join(A))


n = int(input())
a = list(map(int, input().split()))
maxi = 0
b = []
for i in a:
	sumi = i + maxi
	b.append(sumi)
	if sumi > maxi:
		maxi = sumi
print(*b)


n = int(input())
x = [int(q) for q in input().split()]
l = [x[0], x[0] + x[1]]
m = max(l[0], l[1])
for i in range(2, n):
	m = max(l[i - 1], m)
	l.append(x[i] + m)
print(*l)


from sys import stdin, stdout
t = int(stdin.readline())
l = [int(x) for x in stdin.readline().split()]
maxi = 0
for x in l:
	print(str(x + maxi), end=' ')
	if x + maxi > maxi:
		maxi = x + maxi


n = int(input())
l = [int(i) for i in input().split()]
s = 0
neg = 0
for i in l:
	if i >= 0:
		s += i
		print(s, end=' ')
	else:
		neg = s
		neg += i
		print(neg, end=' ')


import sys
input = lambda : sys.stdin.readline().rstrip()
n = int(input())
b = [int(i) for i in input().split()]
cur = 0
ans = []
for i in b:
	ans.append(i + cur)
	if i > 0:
		cur += i
print(*ans)


import math

def sol():
	n = int(input())
	A = [int(i) for i in input().split()]
	B = []
	x = 0
	for i in range(n):
		A[i] += x
		x = max(x, A[i])
		B.append(A[i])
	print(*B, sep=' ')
sol()


n = int(input())
b = [int(s) for s in input().split()]
a = [0] * n
a[0] = b[0]
ma = b[0]
for i in range(1, n):
	a[i] = ma + b[i]
	if b[i] > 0:
		ma += b[i]
print(*a)


import bisect
from functools import lru_cache
n = int(input())
arr = list(map(int, input().split(' ')))
ans = [0] * n
ans[0] = arr[0]
maxito = ans[0]
for i in range(1, n):
	maxito = max(maxito, ans[i - 1])
	ans[i] = maxito + arr[i]
a = ' '.join(list(map(str, ans)))
print(a)


N = int(input())
b = list(map(int, input().split()))
a = []
for i in range(N):
	if i == 0:
		a.append(b[0])
		max_v = b[0]
	else:
		a.append(max_v + b[i])
		max_v = max(max_v, a[i])
print(' '.join(map(str, a)))


def R():
	return map(int, input().split())

def I():
	return int(input())

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
from itertools import permutations
import bisect
n = I()
b = L()
a = [0] * n
a[0] = b[0]
maxa = a[0]
for i in range(1, n):
	maxa = max(maxa, a[i - 1])
	a[i] = b[i] + maxa
print(*a)


import sys
from math import ceil, floor
import bisect
RI = lambda : [int(x) for x in sys.stdin.readline().split()]
rw = lambda : sys.stdin.readline().strip()
n = int(input())
b = RI()
maxa = max(0, b[0])
ans = [b[0]]
for i in range(1, len(b)):
	ans.append(b[i] + maxa)
	maxa = max(maxa, ans[-1])
for i in ans:
	print(i, end=' ')


n = int(input())
l = list(map(int, input().split()))
m = 0
a = []
for i in l:
	a.append(i + m)
	if i + m > m:
		m = i + m
print(*a)


n = int(input())
b = list(map(int, input().split()))
a = [b[0], b[1] + b[0]]
ma = max(a)
for x in range(2, n):
	num = b[x] + ma
	a.append(num)
	if num > ma:
		ma = num
print(*a)


n = int(input())
t = list(map(int, input().rstrip().split()))
j = 0
k = []
k.append(0)
for i in range(n):
	if j < k[i]:
		j = k[i]
	k.append(t[i] + j)
for h in range(len(k) - 1):
	print(k[h + 1], end=' ')


n = int(input())
a = list(map(int, input().split()))
sum = 0
ans = []
for i in a:
	ans.append(sum + i)
	sum += max(0, i)
print(*ans)


n = int(input())
array = list(map(int, input().split()))
result = []
sums = 0
maxi = 0
for x in array:
	sums = maxi + x
	result.append(sums)
	if sums > maxi:
		maxi = sums
print(*result)


import sys
input = sys.stdin.readline
n = int(input())
x = []
mx = 0
v = list(map(int, input().split()))
for el in v:
	x.append(el + mx)
	mx = max(mx, el + mx)
print(*x)


data = input().rstrip().split()
n = int(data[0])
data = input().rstrip().split()
bb = [int(d) for d in data]
mmax = bb[0]
xx = [0]
aa = [bb[0]]
for i in range(1, n):
	aa.append(bb[i] + mmax)
	if bb[i] > 0:
		mmax += bb[i]
d = ' '
print(d.join([str(a) for a in aa]))


import sys
input = sys.stdin.readline
n = int(input())
b = [int(x) for x in input().split()]
x = [0 for i in range(n)]
a = [0 for i in range(n)]
a[0] = b[0]
for i in range(1, n):
	x[i] = max(0, a[i - 1], x[i - 1])
	a[i] = b[i] + x[i]
for i in a:
	print(i, end=' ')


import sys
import math
from collections import deque

def read_line():
	return sys.stdin.readline()[:-1]

def read_int():
	return int(sys.stdin.readline())

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]
n = read_int()
b = read_int_line()
m = -1
a = [0] * n
i = 2
a[0] = b[0]
a[1] = b[1] + a[0]
m = max(a[0], a[1])
while i < n:
	a[i] = b[i] + m
	m = max(a[i], m)
	i += 1
print(*a)


def main():
	n = int(input())
	b = list(map(int, input().split()))
	m = 0
	for i in range(len(b)):
		print(b[i] + m, end=' ')
		m += max(0, b[i])
main()


n = int(input())
l = list(map(int, input().split()))
ans = []
m = 0
for i in range(n):
	if i == 0:
		m = max(m, l[0])
		ans.append(l[0])
		print(ans[i], end=' ')
		continue
	ans.append(l[i] + m)
	print(ans[i], end=' ')
	m = max(m, ans[i])


n = int(input())
b = [int(x) for x in str(input()).split(' ')]
a = [b[0]]
maxVal = b[0]
for i in range(1, len(b)):
	a.append(b[i] + maxVal)
	if a[-1] > maxVal:
		maxVal = a[-1]
print(' '.join([str(x) for x in a]))


n = int(input())
a = [int(i) for i in input().split()]
v = 0
for i in range(0, len(a)):
	z = a[i] + v
	v = max(v, z)
	print(z, end=' ')


from functools import lru_cache
from collections import *
n = int(input())
B = [*map(int, input().split())]
res = []
curMax = 0
for b in B:
	res.append(b + curMax)
	curMax = max(curMax, res[-1])
print(' '.join(map(str, res)))


n = int(input())
li = list(map(int, input().split()))
ansli = []
mx = 0
for i in range(n):
	if i == 0:
		ansli.append(li[0])
	else:
		mx = max(mx, ansli[i - 1])
		ansli.append(li[i] + mx)
		mx = max(mx, ansli[i])
for i in ansli:
	print(i, end=' ')


n = int(input())
b = list(map(int, input().split()))
ans = []
ans.append(b[0])
maxi = b[0]
for i in range(1, n):
	ans.append(maxi + b[i])
	maxi = max(maxi, maxi + b[i])
print(*ans)


n = int(input())
mx = 0
s = [int(i) for i in input().split()]
for i in range(n):
	print(s[i] + mx, '', end='')
	mx = max(s[i] + mx, mx)


def main():
	n = int(input())
	b_arr = [int(b) for b in input().split()]
	a_prev = 0
	for i in range(n):
		if i == 0:
			print(b_arr[i], end=' ')
			a_prev = b_arr[i]
			continue
		a = a_prev + b_arr[i]
		if a > a_prev:
			a_prev = a
		print(a, end=' ')
	print('')
main()


n = int(input())
r = [int(x) for x in input().split()]
maximum = 0
for i in range(n):
	if r[i] > 0:
		maximum += r[i]
		print(maximum, end=' ')
	else:
		print(maximum + r[i], end=' ')


N = int(input())
X = list(map(int, input().split()))
MyList = [X[0]]
Max = X[0]
for i in range(1, N):
	MyList.append(Max + X[i])
	Max = max(Max, MyList[-1])
print(*MyList)


t = input()
inp = input()
lis = inp.split()
maxa = 0
for i in lis:
	n = int(i)
	curA = n + maxa
	if curA > maxa:
		maxa = curA
	print(curA, end=' ')


n = int(input())
l = list(map(int, input().split()))
ans = []
ans.append(l[0])
max = l[0]
for i in range(1, len(l) - 1):
	temp = max + l[i]
	ans.append(temp)
	if temp > max:
		max = temp
ans.append(max + l[len(l) - 1])
print(*ans)


import sys
n = int(sys.stdin.readline().strip())
line = sys.stdin.readline().strip().split(' ')
b_arr = [int(x) for x in line]
a_arr = [0] * n
a_arr[0] = b_arr[0]
current_max = max(0, a_arr[0])
for i in range(1, n):
	a_arr[i] = b_arr[i] + current_max
	current_max = max(current_max, a_arr[i])
a_str = [str(a) for a in a_arr]
print(' '.join(a_str))


def main_function():
	n = int(input())
	B = list(map(int, input().split(' ')))
	s = str(B[0]) + ' '
	maxi = B[0]
	for k in range(1, len(B)):
		s += str(B[k] + maxi) + ' '
		maxi = max(maxi, B[k] + maxi)
	print(s[:-1])
main_function()


input()
data = list(map(int, input().split()))
m = 0
for (index, value) in enumerate(data):
	data[index] = value + m
	if value >= 0:
		m = data[index]
print(' '.join(map(str, data)))


n = int(input())
l = [int(i) for i in input().split()]
m = 0
for i in range(0, n):
	k = l[i] + m
	print(k, end=' ')
	if m < k:
		m = k


n = int(input())
l = list(map(int, input().split()))
k = [0, l[0]]
cur = l[0]
for t in range(1, n - 1):
	kc = l[t] + cur
	k.append(max(kc, k[-1]))
	cur = k[-1]
for t in range(n):
	k[t] += l[t]
print(*k)


n = int(input())
b = [int(i) for i in input().split()]
(a, r) = ([], 0)
c = 0
for i in range(n):
	r = b[i] + c
	a.append(r)
	if r > c:
		c = r
print(*a)


n = int(input())
s = list(map(int, input().split()))
a = [0]
maxi = a[0]
for i in range(0, n):
	k = s[i] + maxi
	if k > maxi:
		maxi = k
	a.append(k)
	print(k, end=' ')


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
n = val()
b = li()
x = 0
a = []
for i in range(n):
	a.append(b[i] + x)
	x = max(x, a[i])
print(*a)


import collections
import math

def sort(key):
	return key[1]

def pack(key):
	return key[0]

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def solve(lst):
	mx = lst[0]
	ans = []
	m = 0
	ans.append(lst[0])
	for i in range(1, len(lst)):
		ans.append(mx + lst[i])
		mx = max(mx + lst[i], mx)
	ans = [str(i) for i in ans]
	return ' '.join(ans)
k = int(input())
lst = list(map(int, input().split()))
print(solve(lst))


from sys import stdin, stdout
from collections import defaultdict, Counter
from functools import lru_cache
from math import gcd, floor, ceil

def ilist():
	return [int(x) for x in stdin.readline().strip().split(' ')]

def iint():
	return int(stdin.readline().strip())

def istr():
	return stdin.readline().strip()
t = 1
for _x in range(t):
	n = iint()
	arr = ilist()
	maxi = 0
	for i in range(n):
		arr[i] += maxi
		maxi = max(arr[i], maxi)
	print(' '.join(map(str, arr)))


n = int(input())
brr = list(map(int, input().split()))
arr = []
arr.append(brr[0])
x = 0
for j in range(1, n):
	arr.append(brr[j] + max(x, arr[j - 1]))
	x = max(x, arr[j - 1])
for k in arr:
	print(k, end=' ')


n = int(input())
L = list(map(int, input().split()))
M = [0] * n
mx = 0
for i in range(len(L)):
	if i == 0:
		M[i] = L[i]
	else:
		M[i] = L[i] + mx
	mx = max(M[i], mx)
for i in M:
	print(i, end=' ')


length = int(input())
values = list(map(lambda x: int(x), input().split()))
result = [0] * length
result[0] = values[0]
maximum = 0
for i in range(1, length):
	if result[i - 1] > maximum:
		maximum = result[i - 1]
	result[i] = values[i] + maximum
for item in result:
	print(item, end=' ')


n = int(input())
b = list(map(int, input().split()))
max_x = 0
for i in range(n):
	a = b[i] + max_x
	if a > max_x:
		max_x = a
	print(a, end=' ')


n = int(input())
b = [int(i) for i in input().split()]
a = [b[0]]
k = b[0]
for i in range(1, n):
	k = max(k, a[i - 1])
	a.append(b[i] + k)
print(*a)


n = int(input())
b = [int(x) for x in input().split()][:n]
sum = 0
for i in range(n):
	print(sum + b[i], end=' ')
	if b[i] > 0:
		sum = sum + b[i]


n = int(input())
arr = list(map(int, input().split()))
st = []
for i in range(n):
	if i == 0:
		st.append(0)
	elif i == 1:
		st.append(arr[0])
	else:
		st.append(max(st[-1], arr[i - 1] + st[-1]))
ar = [None] * n
for i in range(n):
	ar[i] = arr[i] + st[i]
print(*ar)


a = int(input())
z = list(map(int, input().split()))
ans = [z[0]]
maxa = 0
for i in range(1, len(z)):
	maxa = max(maxa, ans[-1])
	if z[i] == 0:
		ans.append(maxa)
	else:
		ans.append(maxa + z[i])
print(' '.join(map(str, ans)))


maxx = 0
n = int(input())
lst = list(map(int, input().split()))
newlst = []
for i in lst:
	newlst.append(i + maxx)
	maxx = max(maxx, i + maxx)
print(*newlst)


n = int(input())
inp = input().split(' ')
for i in range(n):
	inp[i] = int(inp[i])
print(inp[0], end=' ')
ma = inp[0]
i = 1
while i < n:
	tmp = inp[i] + ma
	print(tmp, end=' ')
	if tmp > ma:
		ma = tmp
	i += 1


def solve():
	n = int(input())
	ll = list(map(int, input().split()))
	ans = []
	mx = 0
	for i in ll:
		ans.append(mx + i)
		mx = max(mx, ans[-1])
	print(*ans)
	return
solve()


from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 500010
MOD = 10 ** 9 + 7
spf = [i for i in range(MAXN)]
spf[0] = spf[1] = -1

def sieve():
	for i in range(2, MAXN, 2):
		spf[i] = 2
	for i in range(3, int(MAXN ** 0.5) + 1):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def fib(n, m):
	if n == 0:
		return [0, 1]
	else:
		(a, b) = fib(n // 2)
		c = a % m * (b % m * 2 - a % m) % m
		d = a % m * (a % m) % m + b % m * b % m % m
		if n % 2 == 0:
			return [c, d]
		else:
			return [d, c + d]

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN(x=' '):
	return list(map(int, sys.stdin.readline().strip().split(x)))

def ncr(n, r):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % MOD
		den = den * (i + 1) % MOD
	return num * pow(den, MOD - 2, MOD) % MOD

def flush():
	return sys.stdout.flush()
n = int(input())
b = arrIN()
a = [0] * n
a[0] = b[0]
mx = a[0]
for i in range(1, n):
	a[i] = b[i] + mx
	mx = max(mx, a[i])
print(*a)


n = int(input())
max = 0
for i in list(map(int, input().split())):
	if i >= 0:
		max = max + i
		print(max, end=' ')
	else:
		print(max + i, end=' ')


n = int(input())
(*b,) = map(int, input().split())
a = []
mx = 0
for i in range(n):
	a.append(b[i] + mx)
	mx = max(mx, a[-1])
print(*a)


am = int(input())
arr = list(map(int, input().split()))
newArr = [arr[0]]
maxWas = arr[0]
for i in range(1, am):
	newArr.append(arr[i] + max(newArr[i - 1], maxWas))
	maxWas = max(newArr[i], maxWas)
print(*newArr)


n = int(input())
b = list(map(int, input().split(' ')))
a = [b[0]]
m = 0
for x in b[1:]:
	if m < a[-1]:
		m = a[-1]
	a += [x + m]
print(' '.join([str(ai) for ai in a]))


_ = input()
arr = list(map(int, input().split()))
a = [0 for i in arr]
m = 0
a[0] = arr[0]
if a[0] > m:
	m = a[0]
a[1] = arr[1] + m
if a[1] > m:
	m = a[1]
for i in range(2, len(arr)):
	a[i] = arr[i] + m
	if a[i] > m:
		m = a[i]
print(*a)


def big_array(arr):
	suma = 0
	ans = []
	for i in range(len(arr)):
		if arr[i] >= 0:
			val = suma + arr[i]
			ans.append(val)
			suma += arr[i]
		else:
			val = suma + arr[i]
			ans.append(val)
	for i in ans:
		print(i, '', end='')
	print()
n = int(input())
arr = list(map(int, input().rstrip().split()))
big_array(arr)


n = int(input())
l = [int(x) for x in input().split()]
untillMax = l[0]
r = [-1 for i in range(n)]
r[0] = l[0]
untillMax = r[0]
for i in range(1, n):
	r[i] = untillMax + l[i]
	if r[i] > untillMax:
		untillMax = r[i]
for i in r:
	print(i, end=' ')


import sys
input = sys.stdin.readline
n = int(input())
array = list(map(int, input().split()))
ans = []
maxi = 0
for i in array:
	ans.append(maxi + i)
	maxi = max(maxi, ans[-1])
print(*ans)


n = int(input())
list_b = [int(x) for x in input().split()]
list_a = [list_b[0]]
max = list_a[0]
for i in range(1, n):
	if list_a[i - 1] > max:
		max = list_a[i - 1]
	list_a.append(list_b[i] + max)
a = ''
for i in list_a:
	a += str(i)
	a += ' '
print(a)


n = int(input())
b = list(map(int, input().split()))
max = b[0]
for i in range(1, n):
	b[i] = b[i] + max
	if b[i] > max:
		max = b[i]
print(*b)


n = int(input())
ar = [int(x) for x in input().split()]
ans = [ar[0]]
mx = ar[0]
for i in range(1, n):
	val = ar[i] + mx
	ans.append(val)
	mx = max(mx, val)
for i in ans:
	print(i, end=' ')


input()
b = list(map(int, input().split()))
a = list()
sumnum = 0
negnum = 0
for i in range(len(b)):
	sumnum += b[i]
	a.append(sumnum + abs(negnum))
	if b[i] < 0:
		negnum += b[i]
print(*a)


import sys
n = int(input())
b = [int(i) for i in input().split()]
a = [b[0]]
max_ = a[0]
for i in range(1, n):
	a.append(b[i] + max(max_, a[-1]))
	max_ = max(max_, a[-1])
print(*a)


t = int(input())
a = list(map(int, input().split()))
b = [a[0]]
ma = a[0]
for i in range(1, t):
	c = a[i] + ma
	if c > ma:
		ma = c
	b.append(c)
print(*b)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def in1():
	return int(input())

def in3():
	return map(int, input().split())

def inx():
	return [int(_) for _ in input().split()]
n = in1()
b = inx()
a = []
m = 0
for (i, it) in enumerate(b):
	z = it + m
	a.append(str(z))
	m = max(m, z)
print(' '.join(a))


n = int(input())
w = [int(k) for k in input().split()]
mx = 0
res = []
for j in w:
	res.append(j + mx)
	mx = max(mx, res[-1])
print(' '.join([str(k) for k in res]))


n = int(input())
lis = list(map(int, input().split()))
ans = []
ans.append(lis[0])
m = lis[0]
for i in range(1, n):
	now = m + lis[i]
	ans.append(now)
	m = max(m, now)
print(*ans)


n = int(input())
b = list(map(int, input().split()))
solution = [0] * n
x = 0
for i in range(n):
	solution[i] = b[i] + x
	x = max(solution[i], x)
print(*solution)


import io, os
from collections import deque
RL = lambda : list(map(int, input().split()))
n = int(input())
b = RL()
ma = b[0]
a = [ma]
for i in range(1, n):
	ma = max(0, ma, a[i - 1])
	a.append(b[i] + ma)
print(*a)


from math import *
from copy import *
from string import *
from random import *
from bisect import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
from collections import defaultdict

def solve(b):
	n = len(b)
	a = [0] * n
	pos = 0
	maxx = 0
	for i in range(n):
		if i == 0:
			a[i] = b[i]
		else:
			a[i] = maxx + b[i]
		maxx = max(maxx, a[i])
	return a
	for i in range(0, n):
		if b[i] > 0:
			pos += b[i]
		if i == 0:
			a[i] = b[i]
		elif a[i - 1] + b[i] <= 0:
			a[i] = max(0, maxx + b[i])
		else:
			a[i] = max(pos, 0)
		maxx = max(maxx, a[i])
	return a
N = int(stdin.readline())
b = list(map(int, stdin.readline().rstrip().split()))
ans = solve(b)
print(*ans)


n = int(input())
a = list(map(int, input().split()))
maxx = 0
for i in range(1, n):
	maxx = max(maxx, a[i - 1])
	a[i] += maxx
print(*a)


n = int(input())
arr = [int(s) for s in input().split()]
maxi = 0
x = 0
for i in range(len(arr)):
	if arr[i] > 0:
		x += arr[i]
		print(x, end=' ')
	else:
		print(x + arr[i], end=' ')


n = int(input())
A = list(map(int, input().split()))
B = []
ma = 0
for i in range(n):
	B.append(A[i] + ma)
	ma = max(B[i], ma)
print(*B)


n = int(input())
l = list(map(int, input().split()))
maxa = 0
string = ''
a = []
for i in range(0, n):
	a.append(l[i] + maxa)
	if a[i] > maxa:
		maxa = a[i]
	else:
		continue
for i in range(n):
	string += str(a[i]) + ' '
print(string)


n = int(input())
l = [int(i) for i in input().split()]
x = 0
s = []
for i in range(n):
	s.append(l[i] + x)
	x = max(l[i] + x, x)
print(*s)


n = int(input())
b = list(map(int, input().split()))
cmax = b[0]
print(b[0], end=' ')
for i in b[1:]:
	if i < 0:
		print(cmax + i, end=' ')
	else:
		print(cmax + i, end=' ')
		cmax = cmax + i


n = int(input())
b = list(map(int, input().strip().split()))[:n]
out = []
x = 0
for i in range(n):
	out.append(x + b[i])
	x = max(x, out[i])
print(*out)


def f(n, b):
	a = [0 for i in range(n)]
	a[0] = b[0]
	m = 0
	for i in range(1, n):
		m = max(m, a[i - 1])
		a[i] = b[i] + m
	ans = ''
	for j in a:
		ans += str(j) + ' '
	return ans

def main():
	n = int(input())
	b = [int(i) for i in input().split()]
	print(f(n, b))
main()


N = int(input())
b_arr = list(map(int, input().split()))
x_arr = []
a_arr = []
x_arr.append(0)
a_arr.append(b_arr[0])
maxNum = 0
for i in range(1, N):
	maxNum = max(maxNum, a_arr[i - 1])
	x_arr.append(maxNum)
	a_arr.append(b_arr[i] + x_arr[i])
str_a_arr = [str(i) for i in a_arr]
print(' '.join(str_a_arr))


l = int(input())
b = list(map(int, input().split()))
a = [0] * l
m = b[0]
a[0] = b[0]
for i in range(1, l):
	a[i] = b[i] + m
	if a[i] > m:
		m = a[i]
print(*a)


n = int(input())
m = 0
for v in list(map(int, input().split())):
	print(v + m, end=' ')
	m = max(m, m + v)


from sys import stdin
n = int(stdin.readline())
b = list(map(int, stdin.readline().split()))
x = [0]
a = [b[0]]
m = a[0]
for i in range(1, n):
	x.append(m)
	a.append(x[i] + b[i])
	m = max(m, a[-1])
print(' '.join(map(str, a)))


nums = int(input())
bs = list(map(int, input().split()))
outputlist = [str(bs[0])]
highest = bs[0]
for j in range(1, nums):
	outputlist.append(str(bs[j] + highest))
	if int(outputlist[-1]) > highest:
		highest = int(outputlist[-1])
print(' '.join(outputlist))


n = int(input())
w = list(map(int, input().split()))
d = 0
e = 0
for i in range(n):
	if e >= d:
		d = e
	e = w[i] + d
	print(e, end=' ')


N = int(input())
B = list(map(int, input().split()))
A = [0 for i in range(N)]
A[0] = B[0]
m = A[0]
for i in range(1, N):
	if B[i] > 0:
		A[i] = B[i] + m
		m = A[i]
	else:
		A[i] = m + B[i]
print(*A)


def fillPrefixSum(arr, n, prefixSum):
	prefixSum[0] = arr[0]
	p = prefixSum[0]
	for i in range(1, n):
		prefixSum[i] = p + arr[i]
		if prefixSum[i] > p:
			p = prefixSum[i]
n = int(input())
arr = list(map(int, input().split()))
prefixSum = [0 for i in range(n)]
fillPrefixSum(arr, n, prefixSum)
print(*prefixSum)


n = int(input())
a = list(map(int, input().split()))
ma = 0
r = []
for i in a:
	r.append(ma + i)
	ma = max(ma, ma + i)
print(*r)


n = int(input())
bs = tuple((int(x) for x in input().split(' ')))
max_ = 0
as_ = []
for b in bs:
	a = b + max_
	max_ = max(a, max_)
	as_.append(str(a))
print(' '.join(as_))


n = int(input())
(*arr,) = map(int, input().split())
res = []
sliding_max = 0
for num in arr:
	res.append(sliding_max + num)
	sliding_max = max(sliding_max, res[-1])
print(*res)


from sys import stdin, stdout
import bisect
import math

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
			n = n - 1
		else:
			a = a * a
			n = n >> 1
	return r

def occur(l, x):
	for i in range(len(l)):
		if l[i] == x:
			return i

def solve():
	n = inp()
	l = li()
	a = 0
	x = [l[0]]
	for i in range(1, n):
		a = max(a, l[i - 1])
		x.append(l[i] + a)
		a = max(a, l[i] + a)
	print(*x)
for _ in range(1):
	solve()


n = int(input())
b_arr = [int(i) for i in input().split()]
x = 0
for b in b_arr:
	a = b + x
	x = max(x, a)
	print(a, end=' ')


def zad_codeforces(x, y):
	k = 0
	p = 0
	operations = 0
	diff = y - x
	while True:
		if x * pow(10, p + 1) >= y:
			break
		p += 1
	while k != y:
		if diff >= x:
			k += x * pow(10, p)
			diff = y - k
			if p > 0 and diff < x * pow(10, p):
				p -= 1
			operations += 1
		else:
			operations += diff
			k += diff
	return operations

def find_max_given_range(a, n):
	max_val = 0
	for i in range(0, n):
		if a[i] >= max_val:
			max_val = a[i]
	return max_val

def alicia_problem(b, n):
	a = []
	i = 0
	current_max = 0
	while i != n:
		element = b[i] + current_max
		a.append(element)
		if b[i] > 0:
			current_max = a[-1]
		i += 1
	for i in a:
		print(i, end=' ')
req_size = int(input().strip())
data = [int(i) for i in input().strip().split()[:req_size]]
alicia_problem(data, req_size)


(n, a) = (int(input()), list(map(int, input().split())))
(tem, ma) = (0, 0)
for i in range(n):
	if a[i] >= 0:
		ma += a[i]
		print(ma, end=' ')
	else:
		tem = ma + a[i]
		print(tem, end=' ')


n = int(input())
b = [int(i) for i in input().split()]
a = []
x = []
maximum = 0
for (ind, b_i) in enumerate(b):
	a_i = b_i + maximum
	x.append(maximum)
	a.append(a_i)
	maximum = a_i if a_i > maximum else maximum
print(*a)


n = int(input())
x = list(map(int, input().split()))
l = []
k = []
for i in range(n):
	if i == 0:
		l.append(0)
		k.append(x[i])
	else:
		l.append(max(l[-1], k[i - 1]))
		k.append(l[i] + x[i])
for i in k:
	print(i, end=' ')


n = int(input())
B = [int(b) for b in input().split(' ')]
A = []
current_max = 0
for i in range(n):
	a_i = B[i] + current_max
	A.append(str(a_i))
	if a_i > current_max:
		current_max = a_i
print(' '.join(A))


def fun(g):
	ans = [0] * len(g)
	ans[0] = str(g[0])
	ma = int(ans[0])
	for i in range(1, len(g)):
		ans[i] = str(g[i] + ma)
		ma = max(ma, int(ans[i]))
	return ans
n = int(input())
g = list(map(int, input().split()))
print(' '.join(fun(g)))


n = int(input())
arr = list(map(int, input().split()))
req = []
req.append(arr[0])
mx = 0
for i in range(1, n):
	mx = max(mx, req[i - 1])
	req.append(arr[i] + mx)
print(*req)


len = int(input())
arr = input().split(' ')
for i in range(len):
	arr[i] = int(arr[i])
max = arr[0]
for i in range(1, len):
	temp = arr[i - 1]
	if temp > max:
		max = temp
	arr[i] += max
for i in range(len):
	print(arr[i], end=' ')


def sol(n, aa):
	m = 0
	for a in aa:
		yield (a + m)
		m = max(m, a + m)

def main():
	n = int(input())
	aa = [int(x) for x in input().split()]
	print(' '.join((str(x) for x in sol(n, aa))))
main()


n = int(input())
bl = list(map(int, input().split()))
al = []
ma = 0
for i in range(n):
	num = bl[i]
	al.append(num + ma)
	if num + ma > ma:
		ma = num + ma
print(*al)


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())
n = itg()
b = list(mpint())
a = b.copy()
mx = 0
for i in range(1, n):
	mx = max(mx, a[i - 1])
	a[i] += mx
print(*a)


import sys
I = sys.stdin.readline
ans = ''
n = int(I())
arr = list(map(int, I().split()))
a = arr[0]
ans = [arr[0]]
for i in range(1, n):
	prev = a
	a += arr[i]
	ans.append(a)
	a = max(a, prev)
print(*ans)


for i in range(1):
	n = int(input())
	li = list(map(int, input().split()))
	d = []
	x = 0
	for i in li:
		k = i + x
		d.append(k)
		x = max(k, x)
	print(*d)


n = int(input())
b = [int(q) for q in input().split()]
a = []
m = 0
for i in range(n):
	a += [b[i] + m]
	m = max(m, a[i])
print(*a)


n = int(input())
b = list(map(int, input().split(' ')))
x = [0]
a = []
a.append(b[0])
x.append(a[0])
i = 1
while i < n:
	a.append(b[i] + x[i])
	if a[i] > x[i]:
		x.append(a[i])
	else:
		x.append(x[i])
	i += 1
for ele in a:
	print(ele, end=' ')


n = int(input())
ans = []
a = list(map(int, input().split()))
ans.append(a[0])
past = ans[-1]
big = a[0]
for i in range(1, n):
	if a[i] >= 0:
		ans.append(a[i] + past)
		past = ans[-1]
		if ans[-1] > big:
			big = ans[-1]
	elif a[i] < 0 and a[i] < big:
		ans.append(big + a[i])
	else:
		ans.append(0)
print(*ans)


lens = int(input())
arrs = [int(x) for x in input().split()]
answer = []
maxs = 0
for i in range(lens):
	answer.append(maxs + arrs[i])
	maxs += max(arrs[i], 0)
print(*answer)


n = int(input())
b = list(map(int, input().split()))
a = []
num = 0
for i in range(0, n):
	if i == 0:
		a.append(b[i])
		num = b[i]
	else:
		a.append(b[i] + num)
		num = max(num, a[i])
for i in range(n):
	print(a[i], end=' ')


import sys
input = sys.stdin.readline
n = int(input())
b = [int(item) for item in input().split()]
a = []
val = 0
for item in b:
	if item >= 0:
		val += item
		a.append(val)
	else:
		a.append(val + item)
print(*a)


length = int(input())
b = list(map(int, input().split()))
a = []
maxCurrent = b[0]
for i1 in range(length):
	if i1 == 0:
		a.append(b[i1])
		maxCurrent = b[i1]
	elif b[i1] >= 0:
		a.append(maxCurrent + b[i1])
		maxCurrent += b[i1]
	elif b[i1] < 0:
		a.append(maxCurrent + b[i1])
for i1 in a:
	print(i1, end=' ')


n = int(input())
b = [int(i) for i in input().split()]
a = list()
m = 0
for i in b:
	a.append(str(i + m))
	if i > 0:
		m += i
print(' '.join(a))


n = int(input())
B = list(map(int, input().split()))
A = [0] * n
x = 0
for i in range(n):
	if i == 0:
		A[i] = B[i]
	else:
		x = max(x, A[i - 1])
		A[i] = B[i] + x
print(*A)


a = input()
x = [int(x) for x in input().split()]
s = 0
for i in x:
	i = i + s
	s = max(s, i)
	print(i, end=' ')


n = int(input())
b = list(map(int, input().split()))
maxim = b[0]
temp = b[0]
print(b[0], end=' ')
for x in range(1, n):
	maxim = max(maxim, temp)
	temp = maxim + b[x]
	print(temp, end=' ')


n = int(input())
a = list((int(i) for i in input().split()))
m = 0
for j in a:
	print(j + m, end=' ')
	m = max(j + m, m)


n = int(input())
a = 0
b = map(int, input().split())
for i in b:
	print(i + a, end=' ')
	a += max(0, i)


n = int(input())
aa = list(map(int, input().split()))
bb = [aa[0]]
ma = aa[0]
ind = 0
for i in range(1, n):
	if aa[i] > ma:
		bb.append(ma + aa[i])
	else:
		bb.append(ma + aa[i])
	if bb[i] > ma:
		ma = bb[i]
		ind = i
print(*bb)


n = int(input())
a = list(map(int, input().split()))
answer = [0] * n
answer[0] = a[0]
m = 0
for i in range(n):
	answer[i] = m + a[i]
	if a[i] > 0:
		m += a[i]
print(*answer)


N = int(input())
B = list(map(int, input().split()))
Ans = []
cummax = 0
for b in B:
	a = cummax + b
	Ans.append(a)
	cummax = max(cummax, a)
print(' '.join(map(str, Ans)))


n = int(input())
nums = list(map(int, input().split()))
a = []
maxi = nums[0]
a.append(maxi)
for i in range(1, n):
	t = nums[i] + maxi
	if t > maxi:
		maxi = t
	a.append(t)
print(*a)


n = int(input())
l = list(map(int, input().strip().split(' ')))
maxi = l[0]
for i in range(1, n):
	l[i] = maxi + l[i]
	if l[i] > maxi:
		maxi = l[i]
for i in range(n):
	print(l[i], end=' ')


n = int(input())
b = [int(i) for i in input().split()]
x = [0 for i in range(n + 1)]
a = [0 for i in range(n)]
mx = 0
for (ind, i) in enumerate(b):
	if a[ind - 1] > mx:
		mx = a[ind - 1]
	x[ind + 1] = mx
	a[ind] = x[ind + 1] + i
print(*a)


import math
import sys
input = sys.stdin.readline
n = int(input())
arr = list(map(int, input().split()))
ans = [max(arr[0], 0)]
maxx = max(arr[0], 0)
for i in range(1, n):
	ans.append(arr[i] + maxx)
	maxx = max(maxx, ans[-1])
print(*ans)


t = int(input())
arr = list(map(int, input().split()))
x = 0
for i in range(t):
	arr[i] += x
	x = max(arr[i], x)
	print(arr[i], end=' ')


n = int(input())
l = list(map(int, input().split()))
a = [l[0]]
mx = max(0, l[0])
for i in range(1, n):
	ai = l[i] + mx
	mx = max(mx, ai)
	a.append(ai)
print(*a)


input()
b = [int(x) for x in input().split()]
a = [b[0]]
m = 0
for i in range(1, len(b)):
	m = max(m, a[i - 1])
	a.append(b[i] + m)
print(*a)


t = int(input())
li = [int(i) for i in input().split(' ')]
ans = []
big = li[0]
for (idx, i) in enumerate(li):
	if idx == 0:
		ans.append(i)
		continue
	ans.append(i + big)
	big = max(i + big, big)
print(*ans)


n = int(input())
sum = 0
a = list(map(int, input().split()))
for i in range(len(a)):
	if a[i] < 0:
		print(sum + a[i], end=' ')
		continue
	sum += a[i]
	print(sum, end=' ')


from math import factorial
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')

def main():
	n = N()
	arr = list(RL())
	bs = 0
	res = []
	for i in arr:
		res.append(i + bs)
		bs = max(bs, res[-1])
	print(*res)
main()


n = int(input())
s = map(int, input().split())
ans = []
MAX = 0
for x in s:
	ans.append(x + MAX)
	MAX = max(MAX, ans[-1])
	ans[-1] = str(ans[-1])
print(' '.join(ans))


n = int(input())
l = list(map(int, input().split()))
x = len(l)
max = 0
for i in range(x):
	p = l[i] + max
	print(p, end=' ')
	if max < p:
		max = p


t = int(input())
b = [int(k) for k in input().split()]
x = [0] * len(b)
a = [0] * len(b)
a[0] = b[0]
for i in range(1, len(b)):
	x[i] = max(x[i - 1], a[i - 1])
	a[i] = b[i] + x[i]
print(' '.join(map(str, a)))


n = int(input())
b = input().split()
a = 0
out = ''
mx = 0
for i in b:
	a = mx + int(i)
	mx = max(mx, a)
	out += str(a) + ' '
print(out)


n = int(input())
a = [int(i) for i in input().split()]
b = [0 for i in range(n)]
i = 0
while i < n:
	if a[i]:
		break
	i += 1
if i < n:
	d = a[i]
else:
	d = 0
if i < n:
	b[i] = d
i += 1
while i < n:
	if a[i] > 0:
		d += a[i]
		b[i] = d
	else:
		b[i] = d + a[i]
	i += 1
print(*b)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
n = int(input())
array = list(map(int, input().split()))
maxnow = array[0]
ans = [array[0]]
for i in range(n - 1):
	tempmax = array[i + 1] + maxnow
	if tempmax > maxnow:
		maxnow = tempmax
		ans.append(maxnow)
	else:
		ans.append(tempmax)
print(' '.join((str(x) for x in ans)))


def linput(a):
	return [int(i) for i in a.split()]
for ughblnk in range(1):
	r = int(input())
	q = linput(input())
	a = [q[0]]
	if r == 1:
		print(q[0])
	else:
		n = q[0]
		for i in range(1, r):
			w = q[i] + n
			a.append(w)
			if w > n:
				n = w
		print(*a)


n = int(input())
B = [int(x) for x in input().split()]
A = [B[0]]
Max = A[0]
for i in range(1, n):
	A.append(B[i] + Max)
	Max = max(Max, A[-1])
for i in range(n):
	A[i] = str(A[i])
print(' '.join(A))


n = int(input())
p = input().rstrip().split(' ')
S = 10000025500000000000
for i in range(0, len(p)):
	if S == 10000025500000000000 and int(p[i]) < 0:
		print(int(p[i]), end=' ')
	elif int(p[i]) >= 0 and S == 10000025500000000000:
		S = int(p[i])
		print(S, end=' ')
	elif int(p[i]) < 0:
		T = S + int(p[i])
		print(T, end=' ')
	elif int(p[i]) >= 0:
		S += int(p[i])
		print(S, end=' ')


from sys import stdin, stdout
n = int(stdin.readline())
arr = [int(x) for x in stdin.readline().split()]
ans = [0] * n
ans[0] = arr[0]
ans[1] = arr[1] + ans[0]
maxi = max(ans[0], ans[1])
for i in range(2, n):
	maxi = max(maxi, ans[i - 1])
	ans[i] = arr[i] + maxi
print(*ans, sep=' ')


n = int(input())
sp = list(map(int, input().split()))
x = 0
for i in sp:
	print(i + x, end=' ')
	x = max(x, i + x)


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
N = INT()
B = LIST()
X = [0] * N
A = [0] * N
A[0] = B[0]
accmx = A[0]
for i in range(1, N):
	X[i] = accmx
	A[i] = B[i] + X[i]
	accmx = max(accmx, A[i])
print(*A)


n = int(input())
B = [int(i) for i in input().split()]
A = [B[0], B[0] + B[1]]
a_max = max(A[0], A[1])
ind = 1
for j in B[2:]:
	if A[ind] > a_max:
		a_max = A[ind]
	ind += 1
	aj = j + a_max
	A.append(aj)
As = [str(k) for k in A]
print(' '.join(As))


t = int(input())
b = list(map(int, input().split()))
x = 0
a = []
for i in range(t):
	a.append(0)
	a[i] = b[i] + x
	x = max(a[i], x)
print(*a)


n = int(input())
arr_b = list(map(int, input().split()))
arr_a = []
curr_max = 0
for i in range(n):
	arr_a.append(arr_b[i] + curr_max)
	if arr_a[i] > curr_max:
		curr_max = arr_a[i]
arr = list(map(str, arr_a))
ans = ' '.join(arr)
print(ans)


def solve():
	n = int(input())
	arr = [int(x) for x in input().split()]
	print(arr[0], end=' ')
	s = arr[0]
	mx = arr[0]
	for i in range(1, n, 1):
		arr[i] += mx
		print(arr[i], end=' ')
		mx = max(arr[i], mx)
solve()


def fun(x):
	global max
	z = int(x)
	a = z + max
	if z > 0:
		max = a
	print(a, end=' ')
	return 0
n = int(input())
max = 0
l = list(map(fun, input().split()))


def main():
	n = int(input())
	b = list(map(int, input().split()))
	a = []
	a.append(b[0])
	x = b[0]
	for i in range(1, n):
		a.append(b[i] + x)
		if x < b[i] + x:
			x = b[i] + x
	print(*a)
main()


n = int(input())
b = list(map(int, input().split()))
a = [None] * n
a[0] = b[0]
M = b[0]
for i in range(1, n):
	a[i] = M + b[i]
	if M < a[i]:
		M = a[i]
print(*a)


m = input()
lst = [int(x) for x in input().split()]
n = len(lst)
a = 0
x = 0
for i in range(n):
	b = lst[i]
	x = max(x, a)
	a = b + x
	print(a, end=' ')


tamanho = int(input())
vetor = list(map(int, input().split()))
maior = 0
for i in range(tamanho):
	print(vetor[i] + maior, end=' ')
	if vetor[i] + maior > maior:
		maior = vetor[i] + maior


import sys
n = int(sys.stdin.readline())
line = sys.stdin.readline().split()
b = list(map(int, line))
a = [0] * n
maximum = max(b[0], b[1])
for i in range(n):
	if i == 0:
		a[i] = b[i]
	elif i == 1:
		a[i] = b[i] + a[0]
		if a[i] > maximum:
			maximum = a[i]
	else:
		a[i] = b[i] + maximum
		if a[i] > maximum:
			maximum = a[i]
print(' '.join([str(x) for x in a]))


n = int(input())
b = list(map(int, input().split()))
c = b[0]
d = b[1] + c
s = [c, d]
m = max(s)
for i in range(2, n):
	s.append(b[i] + m)
	m = max(m, s[i])
print(*s)


n = int(input())
a = list(map(int, input().split()))
c = []
x = 0
for i in range(n):
	a[i] += x
	x = max(a[i], x)
	c.append(a[i])
print(*c)


n = int(input())
b = list(map(int, input().split()))
x = 0
for i in range(len(b)):
	ai = b[i] + x
	print(ai, end=' ')
	x = max(x, ai)


n = int(input())
B = [int(i) for i in input().split()]
A = [0 for i in range(n)]
A[0] = B[0]
prev_x = 0
for i in range(1, n):
	prev_x = max(prev_x, A[i - 1])
	A[i] = B[i] + prev_x
print(*A)


from sys import stdin

def read_lines(sep=' ', input_type=None):
	_lines = stdin.readlines()
	cast = input_type is not None
	lines = []
	for line in _lines:
		line = line[:-1].split(sep)
		if cast:
			line = [input_type(x) for x in line]
		lines.append(line)
	return lines
lines = read_lines(input_type=int)
t = lines[0]
lines = lines[1:]
for line in lines:
	B = line
	A = [0] * len(B)
	runmax = 0
	for (i, v) in enumerate(B):
		if v >= 0:
			runmax += v
			A[i] = runmax
		else:
			A[i] = v + runmax
print(' '.join(map(str, A)))


n = int(input())
b = list(map(int, input().split()))
a = []
i = 0
x = 0
while i < n:
	a.append(x + b[i])
	x = max(x, a[-1])
	i += 1
print(*a)


a = int(input())
b = list(map(int, input().split()))
c = 0
for item in b:
	r = c + item
	c = max(r, c)
	print(r, end=' ')


M = 0
input()
for O in input().split():
	N = M + int(O)
	if N > M:
		M = N
	print(N, end=' ')


n = int(input())
b = list(map(int, input().split()))
a = []
x = 0
for j in range(n):
	a.append(x + b[j])
	if b[j] > 0:
		x += b[j]
for j in range(n):
	print(a[j], end=' ')


import sys, math
q = 1
for _ in range(q):
	n = int(sys.stdin.readline())
	l = list(map(int, sys.stdin.readline().split()))
	s = 0
	for i in range(n):
		if l[i] < 0:
			print(s + l[i], end=' ')
		else:
			s += l[i]
			print(s, end=' ')


n = int(input())
b = list(map(int, input().split()))
res = [b[0]]
current_max = b[0]
for b_i in b[1:]:
	res.append(b_i + current_max)
	current_max = max(current_max, res[-1])
print(*res)


from collections import deque
from collections import defaultdict
from collections import defaultdict
import math
from functools import reduce
n = int(input())
b = list(map(int, input().split()))
x = [0]
a = []
curr_max = 0
for i in range(len(b)):
	a.append(b[i] + x[-1])
	curr_max = max(curr_max, a[-1])
	x.append(curr_max)
print(*a)


import math
n = input()
a = list(map(int, input().split()))
dif = a[0]
print(dif, end=' ')
for i in range(1, len(a)):
	print(a[i] + dif, end=' ')
	if a[i] > 0:
		dif = a[i] + dif


n = int(input())
l = list(map(int, input().split()))
x = 0
for i in range(n):
	t = l[i] + x
	print(t, end=' ')
	x = max(x, t)


n = int(input())
b = list(map(int, input().split()))
a = []
a.append(b[0])
a.append(b[1] + a[0])
MAX = max(a[0:2])
for i in range(2, n):
	if MAX < a[i - 1]:
		MAX = a[i - 1]
	temp = b[i] + MAX
	a.append(temp)
for i in range(n):
	print(a[i], end=' ')


t = int(input())
num = list(input().split(' '))
num = list(map(int, num))
prev = 0
for i in num:
	print(i + prev, end=' ')
	if i + prev > prev:
		prev += i


def ma(arr):
	max1 = arr[0]
	result = [arr[0]]
	for r in arr[1:]:
		result.append(r + max1)
		if r + max1 > max1:
			max1 = r + max1
	return result
a = int(input())
arr = list(map(int, input().rstrip().split()))
m = ma(arr)
print(*m)


def solve():
	n = int(input())
	b = list(map(int, input().split()))
	now = 0
	res = []
	add = res.append
	for i in b:
		add(now + i)
		if now + i > now:
			now = now + i
	for i in res:
		print(i, end=' ')
solve()


n = int(input())
li = [int(i) for i in input().split()]
start = li[0]
for i in range(1, len(li)):
	li[i] += start
	start = max(start, li[i])
print(*li)


x = int(input())
array = list(map(int, input().split()))
k = 0
MAX = 0
while k < x:
	teste = array[k] + MAX
	print(teste, end=' ')
	if teste > MAX:
		MAX = teste
	k += 1


from sys import stdin
input = stdin.readline
import math
n = int(input())
arr = list(map(int, input().split()))
mx = 0
for i in range(n):
	print(arr[i] + mx, end=' ')
	mx = max(mx, arr[i] + mx)
print()


n = int(input())
B = [int(s) for s in input().split()]
M = [0] * n
A = [0] * n
A[0] = B[0]
for i in range(0, n - 1):
	M[i + 1] = max(M[i], A[i])
	A[i + 1] = B[i + 1] + M[i + 1]
print(' '.join((str(num) for num in A)))


n = int(input())
lst = list(map(int, input().split()))
temp = lst[0]
for i in range(1, n):
	lst[i] = lst[i] + temp
	temp = max(temp, lst[i])
print(*lst)


n = int(input())
a = list(map(int, input().split()))
(s, max1) = ([a[0]], a[0])
for q in range(1, n):
	s.append(a[q] + max1)
	max1 = max(max1, s[-1])
print(*s)


n = int(input())
b = list(map(int, input().split()))
x = 0
for i in b:
	print(i + x, end=' ')
	if i + x > x:
		x = i + x


n = int(input())
arr = [int(k) for k in input().split()]
lis = []
lis.append(arr[0])
lis.append(lis[0] + arr[1])
maxi = max(lis[0], lis[1])
for i in range(2, n):
	lis.append(maxi + arr[i])
	maxi = max(maxi, lis[i])
print(*lis)


q = int(input())
arr = list(map(int, input().split()))
l = []
max1 = 0
for each in arr:
	l.append(max1 + each)
	max1 = max([max1, max1 + each])
print(*l)


n = int(input())
a = list(map(int, input().split(' ')))
sum = []
temp = 0
for i in a:
	if i >= 0:
		temp += i
		sum.append(temp)
	else:
		sum.append(temp + i)
print(*sum)


import math, collections, sys
input = sys.stdin.readline
n = int(input())
b = list(map(int, input().split()))
a = [b[0]]
x = 0
for i in range(1, n):
	x = max(x, a[-1])
	a.append(b[i] + x)
print(*a)


n = int(input())
l = [int(x) for x in input().split()]
g = [0] * n
mx = 0
for i in range(n):
	g[i] = mx + l[i]
	mx = max(g[i], mx)
print(*g)


n = int(input())
brr = list(map(int, input().split()))
arr = [brr[0]]
m = brr[0]
for i in range(1, n):
	arr.append(brr[i] + m)
	m = max(m, arr[i])
print(*arr)


n = int(input())
b = [int(x) for x in input().split()]
mx = 0
for i in b:
	print(i + mx, end=' ')
	mx = max(mx, i + mx)


n = int(input())
l = list(map(int, input().split()))
p = []
s = l[0]
p.append(s)
le = len(l)
for i in range(1, le):
	p.append(s + l[i])
	s = max(s + l[i], s)
for i in p:
	print(i, end=' ')


printn = lambda x: print(x, end='')
inn = lambda : int(input())
inl = lambda : list(map(int, input().split()))
inm = lambda : map(int, input().split())
ins = lambda : input().strip()
DBG = True
BIG = 10 ** 18
R = 10 ** 9 + 7

def ddprint(x):
	if DBG:
		print(x)
n = inn()
b = inl()
x = 0
a = []
pad = ''
for i in range(n):
	aa = b[i] + x
	printn(pad + str(aa))
	pad = ' '
	x = max(x, aa)
print('')


n = int(input())
b = list(map(int, input().split()))
temp = 0
ans = [b[0]]
for i in range(1, n):
	if temp < ans[i - 1]:
		temp = ans[i - 1]
	result = temp + b[i]
	ans.append(result)
for i in range(len(ans)):
	print(ans[i], end=' ')


x = int(input())
lt = list(map(int, input().split()))
sm = []
tp = 0
for i in range(x):
	if lt[i] > 0:
		tp += lt[i]
		print(tp, end=' ')
	else:
		print(tp + lt[i], end=' ')
print()


def process(lst):
	a = [0] * len(lst)
	a[0] = lst[0]
	lastmax = lst[0]
	for i in range(1, len(lst)):
		a[i] = lst[i] + lastmax
		lastmax = max(a[i], lastmax)
	for x in a:
		print(x, end=' ')

def io():
	n = int(input())
	lst = list(map(int, input().split()))
	process(lst)
io()


n = int(input())
L = list(map(int, input().split()))
m = 0
for i in range(n):
	print(m + L[i], end=' ')
	if L[i] > 0:
		m += L[i]


n = int(input())
a = [int(x) for x in input().split()]
k = 0
for i in range(n):
	a[i] += k
	k = max(a[i], k)
for i in a:
	print(i, end=' ')


elementos = int(input())
vet = list(map(int, input().split(' ')))
maior = 0
for k in range(elementos):
	print(vet[k] + maior, end='')
	if k == elementos - 1:
		print()
	else:
		print(' ', end='')
	if maior < vet[k] + maior:
		maior = vet[k] + maior


n = int(input())
bl = [int(x) for x in input().split()]
cur_max = 0
for b in bl:
	new_a = b + cur_max
	print(new_a, end=' ')
	cur_max = max(cur_max, new_a)
print()


n = int(input())
l = list(map(int, input().split()))
curr = l[0]
res = [l[0]]
for i in range(1, len(l)):
	x = curr + l[i]
	res.append(x)
	curr = max(curr, x)
print(' '.join([str(r) for r in res]))


from sys import stdin, stdout
import math
import heapq
t = 1

def aint():
	return int(input().strip())

def lint():
	return list(map(int, input().split()))

def fint():
	return list(map(int, stdin.readline().split()))

def main():
	n = aint()
	l = lint()
	mx = 0
	ans = []
	for i in l:
		ans.append(mx + i)
		mx = max(ans[-1], mx)
	print(*ans)
t = 1
for i in range(t):
	main()


t = int(input())
a = list(map(int, input().split()))
ans = []
m = 0
for i in range(t):
	ans.append(m + a[i])
	m = max(m, ans[i])
print(' '.join(map(str, ans)))


n = int(input())
arr = list(map(int, input().split()))
Max = arr[0]
for (i, j) in enumerate(arr):
	if i >= 1:
		arr[i] = Max + j
		Max = max(Max, arr[i])
for i in arr:
	print(i, end=' ')


n = int(input())
t = input().split()
b = [0] * n
for i in range(n):
	b[i] = t[i]
a = [0] * n
a[0] = int(b[0])
mx = 0
print(a[0], end=' ')
for i in range(1, n):
	mx = max(int(a[i - 1]), mx)
	a[i] = int(b[i]) + mx
	print(a[i], end=' ')


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	n = inp()
	b = inlt()
	a = []
	x = 0
	for i in range(len(b)):
		a.append(b[i] + x)
		x = max([x, a[len(a) - 1]])
	print(' '.join(map(str, a)))
main()


from math import *

def binarySearch(arr, x, i):
	l = i
	r = len(arr) - 1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def js(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] <= x:
			ans = m
			l = m + 1
		else:
			r = m - 1
	return ans

def jg(arr, x, i):
	l = i
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] >= x:
			ans = m
			r = m - 1
		else:
			l = m + 1
	return ans
n = int(input())
ar = list(map(int, input().split()))
ans = [ar[0]]
m = ar[0]
for i in range(1, n):
	ans.append(m + ar[i])
	if m + ar[i] > m:
		m = m + ar[i]
print(*ans)


n = int(input())
b = [int(i) for i in input().split()]
a = []
a.append(b[0])
maxim = b[0]
for i in b[1:]:
	if i > 0:
		maxim += i
		a.append(maxim)
	else:
		a.append(maxim + i)
print(*a)


n = int(input())
b = [int(x) for x in input().split()]
answer = [0] * n
Max = 0
for i in range(n):
	answer[i] = Max + b[i]
	if Max < answer[i]:
		Max = answer[i]
print(*answer)


n = int(input())
b = [int(x) for x in input().split()]
a = [b[0]]
maxi = b[0]
for i in range(1, n):
	if b[i] >= 0:
		a.append(b[i] + maxi)
		maxi += b[i]
	else:
		a.append(b[i] + maxi)
print(*a)


n = int(input())
arr = list(map(int, input().split()))
i = 0
m = 0
while i < n:
	print(arr[i] + m, end=' ')
	m += max(0, arr[i])
	i += 1
print('')


import atexit
import io
import sys
n = int(input())
arr = input().split()
final_arr = []
start = arr[0]
maxV = int(start)
final_arr.append(int(start))
for (x, i) in enumerate(arr):
	if x == 0:
		continue
	int_i = int(i)
	int_i = int_i + maxV
	if int_i > maxV:
		maxV = int_i
	final_arr.append(int(int_i))
print(' '.join(map(str, final_arr)))


n = int(input())
x = input().split(' ')
y = []
for arg in x:
	y.append(int(arg))
max = 0
for i in range(len(y)):
	y[i] += max
	if y[i] > max:
		max = y[i]
ans = ''
for arg in y:
	ans += str(arg)
	ans += ' '
print(ans)


from sys import stdin
try:
	n = int(stdin.readline())
	b = list(map(int, stdin.readline().rstrip().split()))
	a = [0] * n
	a[0] = m = b[0]
	for i in range(1, n):
		a[i] = m + b[i]
		if a[i] > m:
			m = a[i]
	print(*a)
except:
	pass


n = int(input())
a = list(map(int, input().split()))
ma = a[0]
for i in range(1, n):
	a[i] = a[i] + ma
	if a[i] > ma:
		ma = a[i]
for i in range(0, n):
	print(a[i], end=' ')
print('')


def maximum(b_list):
	a = [0] * len(b_list)
	x = [0] * len(b_list)
	a[0] = x[1] = b_list[0]
	for i in range(1, len(b_list) - 1):
		a[i] = x[i] + b_list[i]
		x[i + 1] = max(x[i], a[i])
	a[len(b_list) - 1] = x[len(b_list) - 1] + b_list[len(b_list) - 1]
	return a
t = int(input())
b_list = list(map(int, input().split()))
result = maximum(b_list)
print(*result)


n = int(input())
l = list(map(int, input().split()))
m1 = l[0]
l1 = [0] * n
l1[0] = m1
for i in range(1, n):
	l1[i] = l[i] + m1
	if l1[i] > m1:
		m1 = l1[i]
print(*l1)


n = int(input())
b = list(map(int, input().split()))
maxi = 0
a = []
for j in b:
	a.append(j + maxi)
	maxi = max(maxi, a[-1])
print(*a, sep=' ')


n = int(input())
l = list(map(int, input().split()))
m = 0
for i in l:
	print(m + i, end=' ')
	m = m if m > m + i else m + i


n = int(input())
b = list(map(int, input().split()))
a = []
a.append(str(b[0]))
maxx = b[0]
i = 1
while i < n:
	a.append(str(b[i] + maxx))
	maxx = max(maxx, b[i] + maxx)
	i = i + 1
s = ' '.join(a)
print(s)


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, input().split())

def rlinput():
	return list(map(int, input().split()))

def main():
	n = iinput()
	q = rlinput()
	m = 0
	res = [0] * n
	for i in range(n):
		res[i] = q[i] + m
		m = max(m, res[i])
	print(*res)
for i in range(1):
	main()


import sys
n = int(sys.stdin.readline())
b = list(map(int, sys.stdin.readline().split()))
a = [-1 for _ in range(n)]
a[0] = b[0]
cur = a[0]
for i in range(1, n):
	a[i] = b[i] + cur
	cur = max(cur, a[i])
print(*a)


n = int(input())
arr = list(map(int, str(input()).split()))
arr2 = [0] * n
arr2[0] = arr[0]
x = arr2[0]
for i in range(1, n):
	x = max(x, arr2[i - 1])
	arr2[i] = arr[i] + x
for i in arr2:
	print(i, end=' ')


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, B):
	lastMax = 0
	ret = []
	for (i, x) in enumerate(B):
		ret.append(x + lastMax)
		if x >= 0:
			lastMax = ret[-1]
	return ' '.join(map(str, ret))
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(N,) = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
ans = solve(N, B)
print(ans)


n = int(input())
arr = list(map(int, input().split()))
temp = 0
for i in arr:
	print(temp + i, end=' ')
	if i > 0:
		temp += i


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
n = N()
b = RLL()
res = []
m = 0
for i in b:
	res.append(i + m)
	m = max(m, res[-1])
print_list(res)


try:
	n = int(input())
	li = [int(x) for x in input().split()]
	a = []
	m = 0
	for c in li:
		print(c + m, end=' ')
		if c > 0:
			m += c
except EOFError:
	pass


n = int(input())
b = list(map(int, input().split()))
a = [b[0]]
d = b[0]
for x in b[1:]:
	c = d + x
	if c > d:
		d = c
	a.append(c)
print(' '.join(map(str, a)))


n = int(input())
li = list(map(int, input().split()))
m = 0
x = []
for i in range(n):
	a = li[i] + m
	m = max(a, m)
	x.append(a)
print(*x)


a = []
n = int(input())
x = [int(x) for x in input().split()]
m = 0
for i in range(0, len(x)):
	a.append(x[i] + m)
	print(a[i], end=' ')
	m = max(a[i], m)


import sys
input = sys.stdin.readline
n = int(input().rstrip())
b = list(map(int, input().rstrip().split()))
a = [b[0]]
maximum = b[0]
for i in range(1, n):
	a.append(maximum + b[i])
	maximum = max(maximum, maximum + b[i])
print(*a)


from collections import defaultdict as dc
from collections import deque as dq
from bisect import bisect_left, bisect_right, insort_left
import sys
import math
from heapq import heapify, heappush, heappop
mod = 10 ** 9 + 7

def rem(p, q):
	z = p // q
	r = p - q * z
	return r

def inp():
	p = int(input())
	return p

def line():
	p = list(map(int, input().split()))
	return p
t = 1
for i in range(1):
	n = inp()
	a = line()
	p = []
	s = 0
	z = 0
	for i in range(n):
		if s < z:
			s = z
		z = s
		s = s + a[i]
		p.append(s)
	print(*p)


n = int(input())
b = list(map(int, input().strip().split(' ')))
a = []
x = []
a.append(b[0])
maX = 0
for i in range(1, n, 1):
	if a[i - 1] > maX:
		maX = a[i - 1]
	a.append(b[i] + maX)
for k in range(len(a)):
	print(a[k], end=' ')


n = int(input())
l = [int(x) for x in input().split()]
maxx = 0
for i in range(n):
	print(l[i] + maxx, end=' ')
	maxx = max(maxx, l[i] + maxx)


import os
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
test_count = 1
if debug:
	test_count = int(input())
for t in range(test_count):
	if debug:
		print('Test Case #', t + 1)
	n = inp()
	A = inlt()
	currMax = 0
	ans = list()
	for i in range(n):
		ans.append(A[i] + currMax)
		currMax = max(currMax, ans[i])
	print(' '.join(map(str, ans)))


import sys
n = int(sys.stdin.readline())
b = list(map(int, sys.stdin.readline().rstrip().split(' ')))
max = 0
for bi in b:
	ai = bi + max
	print(ai, end=' ')
	if max < ai:
		max = ai
print('')


from sys import stdin
inp = lambda : stdin.readline().strip()
n = int(inp())
b = [int(x) for x in inp().split()]
a = [b[0], b[1] + b[0]]
big = max(a)
for i in range(n):
	if i > 1:
		a.append(b[i] + big)
	if a[i] > big:
		big = a[i]
print(*a)


n = int(input())
lis = list(map(int, input().split()))
sum1 = lis[0]
for i in range(1, n):
	if lis[i] > 0:
		sum1 += lis[i]
		lis[i] = sum1
	else:
		lis[i] = sum1 + lis[i]
print(*lis)


N = int(input().strip())
B = list(map(int, input().split()))
currentMax = 0
A = []
for b in B:
	bb = b + currentMax
	A.append(bb)
	currentMax = max(bb, currentMax)
print(*A)


from math import *
n = int(input())
b = [int(i) for i in input().split()]
a = [b[0]]
ma = a[0]
for i in range(1, n):
	a.append(b[i] + ma)
	ma = max(ma, a[-1])
print(' '.join(map(str, a)))


n = int(input())
bs = list(map(int, input().split()))
x = 0
As = []
for b in bs:
	nexta = b + x
	x = max(nexta, x)
	As.append(nexta)
print(' '.join(map(str, As)))


n = int(input())
b = [int(ele) for ele in input().split()]
a = []
sumi = 0
for ele in b:
	a.append(sumi + ele)
	sumi = max(sumi, sumi + ele)
for ele in a:
	print(ele, end=' ')


N = int(input())
X = list(map(int, input().split()))
A = [0] * N
mx = 0
for i in range(N):
	A[i] = X[i] + mx
	mx = max(A[i], mx)
print(*A)


n = int(input())
arr = [int(j) for j in input().split()]
ma = 0
ans = []
for i in range(n):
	ans += [arr[i] + ma]
	ma = max(ma, ans[i])
print(*ans)


n = int(input())
bs = map(int, input().split())
ans = []
x = 0
for b in bs:
	a = b + x
	ans.append(a)
	x = max(x, a)
print(' '.join(map(str, ans)))


len_ = int(input())
Result = []
b_list = list(map(int, input().strip().split()))[0:len_]
for i in range(0, len_):
	if i == 0:
		x = 0
		result = b_list[i] + x
		x = result
		Result.append(result)
	else:
		result = b_list[i] + x
		if result > x:
			x = result
		Result.append(result)
for i in Result:
	print(i, end=' ')


n = int(input())
dat = list(map(int, input().split()))
res = []
m = 0
for i in range(n):
	x = m + dat[i]
	m = max(m, x)
	res.append(x)
print(' '.join(list(map(str, res))))


n = int(input())
x = input()
xx = x.split()
s = [0, int(xx[0]), int(xx[0]) + int(xx[1])]
r = max(s)
for i in range(2, n):
	s.append(int(xx[i]) + r)
	if int(xx[i]) >= 0:
		r += int(xx[i])
del s[0]
for i in s:
	print(i, end=' ')


length = int(input())
b = list(map(int, input().split()))
a = [b[0]]
x = [0]
prev = a[0]
index = 1
maxx = a[0]
while index < len(b):
	x.append(maxx)
	a.append(x[index] + b[index])
	if a[-1] > maxx:
		maxx = a[-1]
	index += 1
for i in a:
	print(i, end=' ')


import sys
input = sys.stdin.readline
n = int(input().strip())
b = [int(x) for x in input().strip().split()]
a = []
a.append(b[0])
a.append(b[1] + a[0])
m = max(a)
for bi in range(2, n):
	a.append(b[bi] + m)
	m = max(m, a[-1])
print(*a)


def main():
	n = int(input())
	b = list(map(int, input().split()))
	a = [0] * len(b)
	x_i = b[0]
	a[0] = x_i
	for (i, b_i) in enumerate(b[1:]):
		a_i = b_i + x_i
		x_i = max(a_i, x_i)
		a[i + 1] = a_i
	print(' '.join(map(str, a)))
main()


def f(b):
	m = 0
	for i in range(len(b)):
		b[i] += m
		if b[i] > m:
			m = b[i]
	return b
n = int(input())
l = list(map(int, input().split()))
print(*f(l))


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
n = ii()
b = li()
ans = []
max_ = 0
for i in range(n):
	max_ += max(0, b[i])
	ans.append(max_ + min(0, b[i]))
print(*ans)


n = int(input())
a = list(map(int, input().split()))
orig = []
orig.append(a[0])
maximum = a[0]
for i in range(1, n):
	orig.append(a[i] + maximum)
	if orig[i] > maximum:
		maximum = orig[i]
print(' '.join(map(str, orig)))


n = int(input())
A = list(map(int, input().split()))
B = [A[0]]
t = A[0]
for i in range(1, n):
	B.append(t + A[i])
	t = max(t, t + A[i])
print(*B)


n = int(input())
l = list(map(int, input().split()))
h = l[0]
ans = [h]
for i in range(1, n):
	ans.append(h + l[i])
	h = max(h, h + l[i])
print(*ans)


n = int(input())
b = [int(i) for i in input().split(' ')]
cur = 0
for i in range(n):
	print(b[i] + cur, end=' ')
	cur = cur + max(0, b[i])


T = int(input())
ls = [int(x) for x in input().split()]
max_ = 0
ret = []
for e in ls:
	if e >= 0:
		max_ += e
		ret.append(str(max_))
	else:
		ret.append(str(max_ + e))
print(' '.join(ret))


n = int(input())
nums = list(map(int, input().split()))
pres_max = 0
for i in nums:
	ans = i + pres_max
	pres_max = max(pres_max, ans)
	print(ans, end=' ')
print()


def f1():
	T = int(input())
	for i in range(0, T):
		t = int(input())
		if t == 1:
			print(-1)
			continue
		intx = ''
		for k in range(t - 1):
			intx = intx + '7'
		intx = int(intx)
		for j in range(3, 10):
			if j != 7:
				a = (intx * 10 + j) % 7
				b = (intx * 10 + j) % j
				if a != 0 and b != 0:
					num = intx * 10 + j
					print(num)
					break

def f2():
	N = int(input())
	B = [int(i) for i in input().split(' ')]
	A = [-1] * len(B)
	A[0] = B[0]
	A[1] = B[1] + max(0, A[0])
	lastmax = max(A[1], A[0])
	for i in range(2, len(B)):
		A[i] = B[i] + max(A[i - 1], lastmax)
		lastmax = max(A[i - 1], lastmax)
	for j in range(0, len(A)):
		print(A[j], end=' ')

def f3():
	pass
f2()


a = int(input())
b = 0
c = list(map(int, input().split()))
for i in c:
	if i > 0:
		b += i
		print(b, end=' ')
	elif i < 0:
		print(b + i, end=' ')
	else:
		print(b, end=' ')


from sys import stdin

def main():
	n = int(stdin.readline())
	B = list(map(int, stdin.readline().split()))
	A = [0 for _ in range(n)]
	A[0] = B[0]
	tmp = max(0, A[0])
	for i in range(1, n):
		A[i] = B[i] + tmp
		tmp = max(tmp, A[i])
	print(*A)
main()


n = int(input())
arr = [int(i) for i in input().split()]
res = []
x = 0
for a in arr:
	res.append(x + a)
	x = max(x, x + a)
print(' '.join((str(r) for r in res)))


def uglynum(n):
	if n == 1:
		return -1
	t = '2' + '3' * (n - 1)
	return int(t)

def restore(x):
	y = []
	z = 0
	for i in x:
		y.append(i + z)
		z = max(i + z, z)
	return y
l = int(input())
x = list(map(int, input().split()))
y = restore(x)
print(*y)


import math
n = int(input())
l = list(map(int, input().split()))
x = 0
m = []
for i in range(n):
	l[i] += x
	x = max(x, l[i])
	m.append(l[i])
m = ' '.join(map(str, m))
print(m)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	b.append(a[0])
	max_a = a[0]
	for i in range(1, n):
		max_a = max(max_a, b[i - 1])
		b.append(a[i] + max_a)
	print(' '.join(map(str, b)))
main()


n = int(input())
s = input().strip(' ')
l = list(map(int, s.split()))
max = 0
res = []
for i in l:
	k = max + i
	if k >= max:
		max = k
	print(k, end=' ')


input()
k = list(map(int, input().split()))
ma = k[0]
print(k[0], end=' ')
for x in k[1:]:
	j = x + ma
	print(j, end=' ')
	if j > ma:
		ma = j


import math
from bisect import bisect_left, bisect_right
from sys import stdin, stdout, setrecursionlimit
from collections import Counter
input = lambda : stdin.readline().strip()
print = stdout.write
n = int(input())
ls = list(map(int, input().split()))
arr = []
MAX = 0
for i in ls:
	arr.append(i + MAX)
	MAX = max(MAX, i + MAX)
for i in arr:
	print(str(i) + ' ')
print('\n')


from sys import stdin
n = int(stdin.readline())
b = list(map(int, stdin.readline().split()))
arr = [-1] * n
arr[0] = b[0]
m = max(0, arr[0])
arr[1] = b[1] + m
m = max(m, arr[1])
for i in range(2, n):
	arr[i] = b[i] + m
	m = max(m, arr[i])
print(*arr)


n = int(input())
b = list(map(int, input().split()))
l = []
l.append(b[0])
l.append(b[1] + b[0])
maxi = max(l[0], l[1])
for i in range(2, n):
	temp = b[i] + maxi
	if temp > maxi:
		maxi = temp
	l.append(temp)
for i in l:
	print(i, end=' ')
print()


n = int(input())
list1 = list(map(int, input().split()))
sum = 0
list2 = list()
r = 0
list2.append(0)
ans = list()
maximum = 0
for i in range(n):
	t = list1[i] + maximum
	ans.append(t)
	if t > maximum:
		maximum = t
	list2.append(t)
for i in range(len(ans)):
	print(ans[i], end=' ')


a = int(input())
l = list(map(int, input().split()))
m = l[0]
l1 = []
l1.append(m)
for i in range(1, len(l)):
	l1.append(l[i] + m)
	if l1[i] > m:
		m = l1[i]
for i in l1:
	print(i, end=' ')


def solve():
	n = int(input())
	b = [int(i) for i in input().split()]
	a = [0] * n
	a[0] = b[0]
	d = b[0]
	for i in range(1, len(b)):
		a[i] = b[i] + d
		d = max(a[i], d)
	print(*a)
solve()


lenth = int(input())
num_list = list(map(int, input().split(' ')))
re = []
Max = 0
for i in num_list:
	tem = Max + i
	if tem > Max:
		Max = tem
	re.append(tem)
for i in re:
	print(i, end=' ')


N = int(input())
b = list(map(lambda x: int(x), input().split(' ')))
if len(b) != 0:
	maxn = 0
	a = []
	for i in range(len(b)):
		a.append(b[i] + maxn)
		maxn = max(maxn, a[-1])
	for i in range(len(a) - 1):
		print(a[i], end=' ')
	print(a[-1])


import sys
n = int(sys.stdin.readline())
b = [int(i) for i in sys.stdin.readline().split()]
a = []
maxi = -2
for p in range(n):
	if p == 0:
		a.append(b[0])
	else:
		a.append(maxi + b[p])
	maxi = max(maxi, a[p])
for r in range(n):
	print(a[r], end=' ')
print()


from sys import stdin, stdout
import math
import random

def main():
	n = int(input())
	b = list(map(int, stdin.readline().split()))
	a = []
	a.append(b[0] + 0)
	max_a = max(0, a[0])
	for i in range(1, n):
		a.append(b[i] + max_a)
		max_a = max(max_a, a[i])
	for n in a:
		print(n, end=' ')
	print()
main()


import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
n = int(input())
a = list(mapi())
res = [0] * n
res[0] = a[0]
mx = res[0]
for i in range(1, n):
	res[i] = mx + a[i]
	mx = max(res[i], mx)
print(*res)


from math import ceil, gcd
from math import factorial as fact, comb as ncr
from math import sqrt
from bisect import bisect_left as bl
from bisect import bisect_right as br
from array import array
from collections import Counter as ctr
from collections import deque as dq

def li():
	return list(map(int, input().split()))

def arr(a):
	return array('i', a)

def solve():
	n = int(input())
	b = li()
	a = [0] * n
	m = 0
	for i in range(n):
		a[i] = m + b[i]
		m = max(m, a[i])
	print(*a)
solve()


n = int(input())
b = [*map(int, input().split())]
a = [0 for i in range(len(b))]
x = [0 for i in range(len(b))]
a[0] = b[0]
x[1] = a[0]
for i in range(1, len(b)):
	if b[i - 1] > 0:
		x[i] = b[i - 1] + x[i - 1]
	else:
		x[i] = x[i - 1]
	a[i] = x[i] + b[i]
print(*a)


n = int(input())
mx = 0
lst = list(map(int, input().split()))
ans = []
for i in lst:
	ans.append(mx + i)
	mx = max(mx, ans[-1])
print(*ans)


n = int(input())
arr = list(map(int, input().strip().split()))[:n]
ans = []
max1 = 0
ans.append(arr[0])
max1 = max(max1, arr[0])
for i in range(1, n):
	val = max1 + arr[i]
	ans.append(val)
	max1 = max(max1, val)
for i in ans:
	print(i, end=' ')


t = int(input())
l = list(map(int, input().split()))
x = 0
for i in range(0, len(l), 1):
	l[i] += x
	x = max(x, l[i])
	print(l[i], end=' ')


n = int(input())
ar = list(map(int, input().split()))
ans = []
max_el = 0
for i in range(n):
	ans.append(ar[i] + max_el)
	if ar[i] > 0:
		max_el += ar[i]
print(*ans)


n = int(input())
l = list(map(int, input().split()))
ma = 0
ans = [l[0]]
ma = l[0]
for i in range(1, n):
	if l[i] >= 0:
		ans.append(ma + l[i])
		ma += l[i]
	else:
		ans.append(ma + l[i])
print(*ans)


def func(l, n):
	z = [0] * n
	b = l[0]
	a = b
	z[0] = b
	r = 0
	for i in range(1, n):
		b = l[i]
		r = max(r, a)
		a = b + r
		z[i] = a
	for i in z:
		print(i, end=' ')
	print()
n = int(input())
l = list(map(int, input().split()))
func(l, n)


n = int(input())
b = list(map(int, input().split()))
a = []
a.append(b[0])
temp = 0
for i in range(1, len(b)):
	temp = max(temp, a[i - 1])
	a.append(b[i] + temp)
for ele in a:
	print(ele, end=' ')


class Solution:

	def solve(self, n, a):
		ret = [a[0]]
		m = a[0]
		for i in range(1, n):
			cur = m + a[i]
			ret.append(cur)
			m = max(cur, m)
		return ret

def main():
	inp = lambda : [int(x) for x in input().split()]
	n = int(input())
	a = inp()
	a = Solution().solve(n, a)
	for i in a:
		print(i, end=' ')
	print()
main()


n = int(input())
array = list(map(int, input().split()))
ans = []
maxi = 0
for i in array:
	ans.append(maxi + i)
	maxi = max(maxi, ans[-1])
print(*ans)


n = int(input())
c = list(map(int, input().split()))
ma = 0
d = []
for j in range(n):
	if j == 0:
		d.append(c[j])
		if d[-1] > ma:
			ma = d[-1]
	else:
		d.append(c[j] + ma)
		if d[-1] > ma:
			ma = d[-1]
print(*d, sep=' ')


n1 = int(input())
l1 = list(map(int, input().split()))
r1 = [0]
max = r1[0]
for i in range(0, n1):
	k = l1[i] + max
	if k > max:
		max = k
	r1.append(k)
	print(k, end=' ')


k = input()
n = input().split()
m = 0
for x in map(int, n):
	print(x + m, end=' ')
	m += max(0, x)


from math import ceil, sqrt, floor
n = int(input())
maxi = 0
for i in map(int, input().split()):
	print(maxi + i, end=' ')
	maxi = max(maxi, maxi + i)


n = int(input())
list = [int(i) for i in input().split()]
result = [list[0]]
max = list[0]
print(list[0], end=' ')
for i in range(1, n):
	max = result[i - 1] if max < result[i - 1] else max
	result.append(max + list[i])
	print(result[i], end=' ')


import sys
from math import sqrt
inp = sys.stdin.readline

def is_prime(n):
	for i in range(2, int(sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def a():
	ans = ''
	for _ in range(int(inp())):
		n = int(inp())
		s = ''
		if n == 1:
			s = '-1'
		else:
			s = '2' * (n - 1) + '3'
		ans += s + '\n'
	print(ans)

def b():
	n = int(inp())
	arr = list(map(int, inp().split()))
	arr2 = [arr[0]]
	maxi = arr[0]
	for i in range(1, n):
		arr2.append(maxi + arr[i])
		maxi = max(maxi, arr2[i])
	print(*arr2)
b()


n = int(input())
s = [int(i) for i in input().split()]
x = 0
res = []
for i in s:
	res.append(i + x)
	if i + x > x:
		x = i + x
for i in res:
	print(i, end=' ')


n = int(input())
l = list(map(int, input().split()))
l1 = [0]
l2 = []
y = -99999999999
for i in range(n):
	x = l1[i] + l[i]
	y = max(0, x, y)
	l1.append(y)
	l2.append(x)
print(*l2)


N = int(input())
l = list(map(int, input().split()))
max = l[0]
for i in range(N):
	if i == 0:
		print(l[i], end=' ')
	elif l[i] > 0:
		max = max + l[i]
		print(max, end=' ')
	else:
		k = max + l[i]
		print(k, end=' ')


N = int(input())
B = list(map(int, input().strip().split()))
A = []
A.append(B[0])
A.append(B[0] + B[1])
maxTillNow = max(A[0], A[1])
for i in range(2, len(B)):
	A.append(B[i] + maxTillNow)
	maxTillNow = max(maxTillNow, A[-1])
for n in A:
	print(n, end=' ')


n = int(input())
b = [-1] + list(map(int, input().split()))
a = [-1, b[1], b[2] + b[1]]
maxx = max(a[1], a[2])
for i in range(3, n + 1):
	a.append(b[i] + maxx)
	maxx = max(a[i], maxx)
for i in range(1, n + 1):
	print(a[i], end=' ')
print(' ')


def read_int():
	return int(input())

def read_int_n():
	return list(map(int, input().split()))

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

def read_str():
	return input().strip()

def read_str_n():
	return list(map(str, input().split()))

def slv(N, B):
	A = [B[0]]
	ma = A[0]
	for b in B[1:]:
		A.append(b + ma)
		ma = max(A[-1], ma)
	return A

def main():
	N = read_int()
	B = read_int_n()
	print(*slv(N, B))
main()


def get_vector():
	return list(map(int, input().split()))

def print_vector(vec, sep=' '):
	print(sep.join(map(str, vec)))
n = int(input())
b = get_vector()
(a, run_max) = ([0] * n, 0)
for (i, v) in enumerate(b):
	a[i] = v + run_max
	run_max = max(run_max, a[i])
print_vector(a)


from __future__ import division, print_function
import math
import os
import sys
from fractions import *
from sys import *
from io import BytesIO, IOBase
from itertools import *
from collections import *
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def regularbracket(t):
	p = 0
	for i in t:
		if i == '(':
			p += 1
		else:
			p -= 1
		if p < 0:
			return False
	else:
		if p > 0:
			return False
		else:
			return True

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def reverse1(string):
	pp = ''
	for i in string[::-1]:
		pp += i
	if pp == string:
		return True
	return False

def reverse2(list1):
	l = []
	for i in list1[::-1]:
		l.append(i)
	if l == list1:
		return True
	return False

def mex(list1):
	p = max(list1) + 1
	for i in range(len(list1)):
		if list1[i] != i:
			p = i
			break
	return p

def sumofdigits(n):
	n = str(n)
	s1 = 0
	for i in n:
		s1 += int(i)
	return s1

def perfect_square(n):
	s = math.sqrt(n)
	if s == int(s):
		return True
	return False

def roman_number(x):
	if x > 15999:
		return
	value = [5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
	symbol = ['F', 'MF', 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
	roman = ''
	i = 0
	while x > 0:
		div = x // value[i]
		x = x % value[i]
		while div:
			roman += symbol[i]
			div -= 1
		i += 1
	return roman

def soretd(s):
	for i in range(1, len(s)):
		if s[i - 1] > s[i]:
			return False
	return True

def countRhombi(h, w):
	ct = 0
	for i in range(2, h + 1, 2):
		for j in range(2, w + 1, 2):
			ct += (h - i + 1) * (w - j + 1)
	return ct

def countrhombi2(h, w):
	return h * h // 4 * (w * w // 4)

def binpow(a, b):
	if b == 0:
		return 1
	else:
		res = binpow(a, b // 2)
	if b % 2 != 0:
		return res * res * a
	else:
		return res * res

def binpowmodulus(a, b, m):
	a %= m
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a = a * a % m
		b >>= 1
	return res

def coprime_to_n(n):
	result = n
	i = 2
	while i * i <= n:
		if n % i == 0:
			while n % i == 0:
				n //= i
			result -= result // i
		i += 1
	if n > 1:
		result -= result // n
	return result

def prime(x):
	if x == 1:
		return False
	else:
		for i in range(2, int(math.sqrt(x)) + 1):
			if x % i == 0:
				return False
		else:
			return True

def luckynumwithequalnumberoffourandseven(x, n, a):
	if x >= n and str(x).count('4') == str(x).count('7'):
		a.append(x)
	elif x < 1000000000000.0:
		luckynumwithequalnumberoffourandseven(x * 10 + 4, n, a)
		luckynumwithequalnumberoffourandseven(x * 10 + 7, n, a)
	return a

def luckynuber(x, n, a):
	p = set(str(x))
	if len(p) <= 2:
		a.append(x)
	if x < n:
		luckynuber(x + 1, n, a)
	return a

def interact(type, x):
	if type == 'r':
		inp = input()
		return inp.strip()
	else:
		print(x, flush=True)

def mergeSort(arr):
	if len(arr) > 1:
		mid = len(arr) // 2
		L = arr[:mid]
		R = arr[mid:]
		mergeSort(L)
		mergeSort(R)
		i = j = k = 0
		while i < len(L) and j < len(R):
			if L[i] < R[j]:
				arr[k] = L[i]
				i += 1
			else:
				arr[k] = R[j]
				j += 1
			k += 1
		while i < len(L):
			arr[k] = L[i]
			i += 1
			k += 1
		while j < len(R):
			arr[k] = R[j]
			j += 1
			k += 1
res = set()

def solve(p, l, a, b, n):
	if p > n or l > 10:
		return
	if p > 0:
		res.add(p)
	solve(p * 10 + a, l + 1, a, b, n)
	solve(p * 10 + b, l + 1, a, b, n)

def main():
	n = inpu()
	b = lis()
	s = 0
	l = []
	for i in range(n):
		if b[i] > 0:
			s += b[i]
			l.append(s)
		else:
			s += b[i]
			l.append(s)
			s -= b[i]
	print(*l)
main()


input()
x = list(map(int, input().split()))
sol = [x[0]]
m = x[0]
for b in x[1:]:
	sol.append(b + m)
	m = max(m, sol[-1])
print(' '.join([str(b) for b in sol]))


from io import BytesIO
import os
n = int(input())
b = [int(i) for i in input().split()]
a = [b[0]] + [0] * (n - 1)
pref_max = a[0]
for i in range(1, n):
	pref_max = max(pref_max, a[i - 1])
	a[i] = b[i] + pref_max
print(*a)


a = int(input())
b = list(map(int, input().split()))
c = b[0]
d = b[1]
e = [c]
q = 0
for i in range(1, a):
	q = max(q, e[i - 1])
	e += [q + b[i]]
print(*e)


n = int(input())
a = [int(w) for w in input().split()]
b = []
b.append(a[0])
k = 0
for i in range(len(a) - 1):
	if k < b[i]:
		k = b[i]
	b.append(k + a[i + 1])
print(' '.join((str(w) for w in b)))


n = int(input())
b = list(map(int, input().split()))
a = []
maxm = 0
for i in range(n):
	a.append(b[i] + maxm)
	maxm = max(maxm, a[i])
print(*a)


import math
t = 1
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	x = 0
	for j in range(n):
		l[j] += x
		x = max(x, l[j])
		print(l[j], end=' ')
	print()


(n, s, m) = (int(input()), input().split(), 0)
for i in s:
	print(int(i) + m, end=' ')
	m = max(m, int(i) + m)


n = int(input())
b = list(map(int, input().split()))
a = [0] * n
a[0] = b[0]
t = a[0]
i = 1
while i < n:
	a[i] = t + b[i]
	if t < a[i]:
		t = a[i]
	i += 1
print(*a)


n = int(input())
arr = list(map(int, input().split()))
curr_mx = 0
for i in range(n):
	arr[i] += curr_mx
	if arr[i] > curr_mx:
		curr_mx = arr[i]
print(*arr)


n = int(input())
arr = list(map(int, input().split()))
ma = -10 ** 9
new = []
for i in range(len(arr)):
	if i == 0:
		new.append(arr[0])
		ma = arr[0]
	else:
		new.append(arr[i] + ma)
		ma = max(ma, arr[i] + ma)
	print(new[-1], end=' ')
print()


m = int(input())
b = list(map(int, input().rstrip().split()))
a = []
a.append(b[0])
x = a[0]
print(a[0], end=' ')
for i in range(1, len(b)):
	if a[i - 1] > x:
		x = a[i - 1]
	a.append(b[i] + x)
	print(a[i], end=' ')


n = int(input())
b = [int(i) for i in input().split()]
maxi = 0
a = []
for i in b:
	a.append(maxi + i)
	maxi = max(maxi, maxi + i)
print(*a)


R = lambda : map(int, input().split())
n = int(input())
b = list(R())
a = [0] * len(b)
maks = 0
for i in range(len(a)):
	a[i] = b[i] + maks
	maks = max(maks, a[i])
print(*a)


n = input()
arr = input().split()
maximum = 0
for i in arr:
	val = int(i) + maximum
	print(val, end=' ')
	if val > maximum:
		maximum = val


n = int(input())
B = [*map(int, input().split())]
x = 0
for i in range(n - 1):
	x = max(x, B[i])
	B[i + 1] += x
print(*B)


import io
import os
import sys
import math
import heapq
import bisect
import random
import string
import decimal
import functools
import fractions
import itertools
import collections
from sys import stdin, stdout
from io import BytesIO, IOBase
from math import gcd, floor, sqrt, log, factorial
from bisect import bisect_left, bisect_right
from collections import deque, Counter, defaultdict, OrderedDict, namedtuple, UserDict, UserList, UserString
MOD = 1000000007
sys.setrecursionlimit(100000000)
BUFSIZE = 8192
n = int(input())
arr = [int(i) for i in input().split()]
res = []
s = 0
for i in arr:
	if i >= 0:
		s += i
		res.append(s)
	else:
		c = s + i
		res.append(c)
print(*res)


n = int(input())
b = str(input()).split()
for i in range(n):
	b[i] = int(b[i])
	if i == 0:
		m = b[i]
		a = b[i]
	else:
		if a > m:
			m = a
		a = b[i] + m
	print(a, end=' ')


n = int(input())
(ls, ls1) = ([*map(int, input().split())], [])
tmp = 0
for i in range(len(ls)):
	tmp += ls[i]
	print(tmp, end=' ')
	if ls[i] < 0:
		tmp -= ls[i]


n = int(input())
b = [int(i) for i in input().split()]
m = 0
a = []
for i in b:
	a.append(m + i)
	m = max(m, m + i)
for i in a:
	print(i, end=' ')
print()


n = int(input())
y = 0
ans = []
(*z,) = map(int, input().split())
for i in range(n):
	z[i] += y
	y = max(y, z[i])
print(*z)


n = int(input())
arr = list(map(int, input().split()))
maxx = 0
tempsum = 0
a = list()
for i in range(n):
	if i == 0:
		a.append(arr[i])
		maxx = arr[i]
		tempsum = arr[i]
	elif arr[i] < maxx:
		a.append(arr[i] + maxx)
		if arr[i] > 0:
			maxx += arr[i]
	else:
		a.append(arr[i] + maxx)
		maxx = arr[i] + maxx
print(*a)


n = int(input())
b = list(map(int, input().split()))
x = [0] * len(b)
a = [b[0]] * len(b)
maximum = a[0]
for i in range(1, len(b)):
	x[i] = maximum
	a[i] = x[i] + b[i]
	if a[i] > maximum:
		maximum = a[i]
print(*a, sep=' ')


N = int(input())
B = list(map(int, input().split()))
mx = 0
A = []
for b in B:
	ans = mx + b
	print(ans, end=' ')
	mx = max(ans, mx)


from math import ceil, sqrt, log

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def main():
	n = ii()
	a = li()
	x = 0
	for i in range(n):
		y = a[i] + x
		print(y, end=' ')
		x = max(x, y)
main()


n = int(input())
s = list(map(int, input().split()))
ans = []
for i in range(len(s)):
	if len(ans) == 0:
		ans.append(s[i])
		maxx = s[i]
	else:
		ans.append(s[i] + maxx)
		if s[i] + maxx > maxx:
			maxx = s[i] + maxx
print(*ans)


n = int(input())
b = [int(x) for x in input().split()]
vec = []
x = 0
a = 0
for i in range(n):
	a = x + b[i]
	vec.append(a)
	x = max(x, a)
for i in vec:
	print(i, end=' ')


n = int(input())
b = list(map(int, input().split()))
a = []
for i in range(n):
	if i == 0:
		a += [b[0]]
		print(a[0], end=' ')
	elif i == 1:
		a += [b[1] + b[0]]
		max1 = a[0]
		print(a[1], end=' ')
	else:
		max1 = max(max1, a[i - 1])
		a += [b[i] + max1]
		print(a[i], end=' ')


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
n = int(input())
arr = get_array()
dp = [0 for i in range(n)]
dp[0] = arr[0]
mx = max(0, dp[0])
for i in range(1, n):
	dp[i] = arr[i] + mx
	mx = max(mx, 0, dp[i])
print(*dp)


t = int(input())
b = input().split()
x = list()
x.append(0)
m = 0
a = []
for i in range(len(b)):
	b[i] = int(b[i])
	if i == 0:
		a.append(b[i])
	else:
		if a[i - 1] > m:
			m = a[i - 1]
		x.append(m)
		a.append(b[i] + x[i])
	print(a[i], end=' ')


n = int(input())
B = [int(x) for x in input().split()]
A = [0] * len(B)
A[0] = B[0]
max_so_far = 0
for i in range(1, len(B)):
	max_so_far = max(max_so_far, A[i - 1])
	A[i] = B[i] + max_so_far
print(' '.join([str(x) for x in A]))


n = int(input())
b = list(map(int, input().split()))
current = b[0]
a = [current]
for x in b[1:]:
	if x > 0:
		current += x
		a.append(current)
	else:
		a.append(current + x)
print(*a)


n = int(input())
a = list(map(int, input().split()))
m = 0
for item in a:
	v = m + item
	print(v, end=' ')
	if v > m:
		m = v


n = int(input())
b_s = list(map(int, input().split()))
max = 0
res = []
for i in range(n):
	a = b_s[i] + max
	if a > max:
		max = a
	res.append(a)
print(*res, sep=' ')


n = int(input())
b = list(map(int, input().split()))
prev = 0
a = []
for i in range(n):
	curr = prev + b[i]
	a.append(curr)
	prev = max(prev, curr)
print(*a)


a = int(input())
li = list(map(int, input().split()))
al = 0
for i in li:
	print(al + i, end=' ')
	if i > 0:
		al += i


n = int(input())
B = list(map(int, input().split()))
A = list()
m = 0
for b in B:
	A.append(m + b)
	if b > 0:
		m += b
print(*A)


n = int(input())
b = list(map(lambda x: int(x), input().split()))
x = 0
a = []
for i in range(0, len(b)):
	a.append(b[i] + x)
	x = max(x, a[i])
	print(a[i], end=' ')
print()


n = int(input())
a = list(map(int, input().split()))
ans = []
s = m = 0
for v in a:
	s += m
	ans += [v + m]
	m = max(v + m, m)
print(*ans)


t = 1
ans = []
while t:
	n = int(input())
	b = list(map(int, input().split()))
	a = []
	x = 0
	for i in range(n):
		b[i] += x
		x = max(x, b[i])
		print(b[i], end=' ')
	t -= 1


n = int(input())
b = [int(x) for x in input().split()]
a = [b[0]]
current_m = max(0, b[0])
for it in b[1:]:
	a.append(it + current_m)
	current_m = max(current_m, a[-1])
print(*a)


n = int(input())
x = list(map(int, input().strip().split()))[:n]
c = 0
for n in x:
	print(n + c, end=' ')
	if c < n + c:
		c = n + c


n = int(input())
l = [int(zax) for zax in input().split()]
q = [str(l[0])]
most = l[0]
for i in range(1, n):
	q.append(str(most + l[i]))
	most = max(most, most + l[i])
print(' '.join(q))


n = int(input())
b = list(map(int, input().split()))
a = [b[0]]
x = [0]
max1 = a[0]
for i in range(n - 1):
	k = i + 1
	ans = max1
	x.append(ans)
	a.append(x[k] + b[k])
	if max1 < a[k]:
		max1 = a[k]
print(*a)


n = int(input())
x = list(map(int, input().split()))
y = [0] * n
ma = 0
for i in range(n):
	y[i] = ma + x[i]
	ma = max(ma, y[i])
for i in y:
	print(i, end=' ')


def main():
	n = int(input())
	b = list(map(int, input().split()))
	x = [0]
	a = []
	maxa = 0
	for i in range(n):
		a.append(b[i] + x[i])
		maxa = max(maxa, a[i])
		x.append(maxa)
	print(*a)
main()


n = int(input())
M = 0
L = list(map(int, input().split()))
for i in range(n):
	L[i] += M
	M = max(M, L[i])
print(*L)


n = int(input())
a = list(map(int, input().split()))
nums = []
b = 0
for i in range(len(a)):
	d = a[i] + b
	if d > b:
		b = d
	nums.append(str(d))
print(' '.join(nums))


n = int(input())
arr = list(map(int, input().split()))
ans = []
ans.append(arr[0])
m = 0
for idx in range(1, len(arr)):
	diff = arr[idx]
	m = max(m, ans[idx - 1])
	ans.append(diff + m)
print(*ans)


n = int(input())
b = [int(x) for x in input().split()]
m = 0
a = []
for i in range(n):
	a.append(m + b[i])
	if a[i] > m:
		m = a[i]
print(' '.join(map(str, a)))


def main():
	n = int(input())
	b = [int(x) for x in input().split()]
	x = 0
	for i in b:
		print(x + i, end=' ')
		x = max(x, x + i)
main()


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def solve():
	n = int(inp())
	ar = lis()
	st = ar[0]
	m = ar[0]
	ans = [ar[0]]
	for i in range(1, n):
		k = ar[i] + m
		if k > m:
			m = k
		ans.append(k)
	printlist(ans)
solve()


n = int(input())
a = [int(i) for i in input().split()]
mx = 0
for i in range(n):
	print(mx + a[i], end=' ')
	if a[i] > 0:
		mx += a[i]


import sys
n = int(input())
b = list(map(int, input().split()))
m = b[0]
print(m, end=' ')
for x in range(1, n):
	print(b[x] + m, end=' ')
	m = max(b[x] + m, m)


import sys

def alele():
	return list(map(int, sys.stdin.readline().strip().split()))

def ilele():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
N = int(input())
A = alele()
print(A[0], end=' ')
c = A[0]
for i in range(1, len(A)):
	print(c + A[i], end=' ')
	c = max(c, c + A[i])


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [input() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [int(input()) for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def divisor(n):
		res = []
		i = 1
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				res.append(i)
				if i != n // i:
					res.append(n // i)
		return res

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

class PriorityQueue:

	def __init__(self, l=[]):
		self.q = l
		heapq.heapify(self.q)
		return

	def push(self, n):
		heapq.heappush(self.q, n)
		return

	def pop(self):
		return heapq.heappop(self.q)

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def main():
	N = Scanner.int()
	B = Scanner.map_int()
	A = [0 for _ in range(N)]
	am = B[0]
	A[0] = B[0]
	for i in range(1, N):
		A[i] = am + B[i]
		am = max(am, A[i])
	print(*A, sep=' ')
main()


n = int(input())
b = list(map(int, input().split(' ')))
ans = []
ans.append(b[0])
ans.append(b[0] + b[1])
if ans[0] > ans[1]:
	m = ans[0]
else:
	m = ans[1]
for i in range(2, n):
	ans.append(m + b[i])
	if ans[i] > m:
		m = ans[i]
for element in ans:
	print(element, end=' ')


t = int(input())
l = list(map(int, input().split(' ')))
ans = []
ans.append(l[0])
t = max(ans)
for x in range(1, len(l)):
	s = t + l[x]
	ans.append(s)
	if s > t:
		t = s
for p in ans:
	print(p, end=' ')


n = int(input())
l = list(map(int, input().split()))
prefix_sum = [l[0]]
for i in range(1, n):
	prefix_sum.append(prefix_sum[-1] + max(0, l[i]))
for i in range(0, n):
	if l[i] < 0:
		prefix_sum[i] += l[i]
print(' '.join(map(str, prefix_sum)))


n = int(input())
inp = list(map(int, input().split()))
res = [inp[0]]
maxx = res[0]
summ = 0
for i in range(1, n):
	summ = inp[i] + maxx
	if summ > maxx:
		maxx = summ
	res.append(summ)
print(*res)


n = int(input())
b = list(map(int, input().split()))
a = ''
maximum = 0
for i in range(n):
	a += str(maximum + b[i]) + ' '
	if b[i] > 0:
		maximum += b[i]
print(a)


n = map(int, input().split())
p = [int(x) for x in input().split()]
q = 0
c = []
for i in p:
	a = q
	q += i
	c.append(q)
	if i <= 0:
		q = a
print(*c)


n = int(input())
b = list(map(int, input().split()))
a = []
a.append(b[0])
maxs = b[0]
for i in range(1, n):
	a.append(b[i] + maxs)
	maxs = max(a[i], maxs)
for j in a:
	print(j, end=' ')


n = int(input())
b = input().split()
b = list(map(lambda x: int(x), b))
a = []
maxTilNow = 0
for i in b:
	j = i + maxTilNow
	a.append(j)
	maxTilNow = j if j > maxTilNow else maxTilNow
print(*a)


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
import string

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
n = ii()
d = li()
cm = 0
ans = []
for i in range(n):
	ans.append(d[i] + cm)
	cm = max(cm, ans[i])
prr(ans, ' ')


n = int(input())
(a, b, l, s) = (0, 0, [], [])
lst = list(map(int, input().split()))
l.append(lst[0])
for (i, j) in enumerate(range(n - 1), start=1):
	a = max(l[i - 1], b) + lst[i]
	l.append(a)
	b = max(l[i - 1], b)
print(*l)


t = int(input())
x = list(map(int, input().split()))
pos_ct = 0
for ele in x:
	if ele > -1:
		pos_ct += ele
		print(pos_ct, end=' ')
	else:
		print(pos_ct + ele, end=' ')


import math
n = int(input())
a = []
b = list(map(int, input().split()))
m = 0
for i in range(n):
	if i == 0:
		a.append(b[i])
		m = b[i]
	else:
		new = m + b[i]
		a.append(new)
		if new > m:
			m = new
print(*a)


import sys
input = sys.stdin.readline
n = int(input().rstrip())
b = list(map(int, input().rstrip().split()))
a = [b[0]]
maxi = b[0]
for i in range(1, n):
	a.append(b[i] + maxi)
	if b[i] > 0:
		maxi = b[i] + maxi
print(*a)


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
from collections import defaultdict as dd, deque

def data():
	return sys.stdin.readline().strip()

def mdata():
	return map(int, data().split())
mod = int(1000000000.0 + 7)
n = int(data())
B = list(mdata())
l = []
a1 = B[0]
a2 = B[1] + a1
l.append(a1)
l.append(a2)
m = max(a1, a2)
for i in range(2, n):
	k = B[i] + m
	l.append(k)
	m = max(m, k)
print(*l)


n = int(input())
b = list(map(int, input().split()))
a = list()
a.append(b[0])
maxx = b[0]
for i in range(1, n):
	z = maxx + b[i]
	a.append(z)
	if maxx < z:
		maxx = z
for i in a:
	print(i, end=' ')


n = int(input())
arr = list(map(int, input().split(' ')))
s = 0
k = []
for i in arr:
	if i < 0:
		k.append(s + i)
	else:
		k.append(s + i)
		s += i
for i in k:
	print(i, end=' ')


def main():
	n = int(input())
	arr = list(map(int, input().strip().split()))
	ret = [-1 for _ in range(n)]
	ret[0] = arr[0]
	maxx = ret[0]
	for i in range(1, n):
		ret[i] = arr[i] + maxx
		maxx = max(maxx, ret[i])
	print(' '.join(list(map(str, ret))))
main()


t = int(input())
l = list(map(int, input().split(' ')))
max1 = l[0]
print(l[0], end=' ')
for i in range(t - 1):
	if l[i] < 0:
		c = max1 + l[i + 1]
		print(c, end=' ')
		if c > max1:
			max1 = c
	else:
		cc = max1 + l[i + 1]
		print(cc, end=' ')
		if cc > max1:
			max1 = cc


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
b = list(map(int, input().split()))
a = [b[0]]
x = a[0]
for i in range(1, n):
	x = max(x, a[-1])
	a.append(b[i] + x)
print(' '.join((str(x) for x in a)))


(n, b) = (int(input()), list(map(int, input().split())))
ai = 0
xi = 0
for bi in b:
	xi = max(ai, xi)
	ai = bi + xi
	print(ai, end=' ')


n = int(input())
arr = list(map(int, input().split()))
max = 0
print(arr[0], end=' ')
if arr[0] > max:
	max = arr[0]
for i in range(1, n):
	print(arr[i] + max, end=' ')
	if arr[i] + max > max:
		max = arr[i] + max
print()


n = int(input())
b = [int(i) for i in input().split()]
ma = b[0]
a = [ma]
for i in b[1:]:
	a.append(ma + i)
	if ma + i > ma:
		ma += i
print(*a)


n = int(input())
L = list(map(int, input().split()))
maxi = 0
s = ''
for i in L:
	m = i + maxi
	if maxi < m:
		maxi = m
	s += str(m)
	s += ' '
print(s)


n = int(input())
b = list(map(int, input().split()))
cur_max = 0
cur_a = b[0]
cur_max = max(cur_a, cur_max)
print(cur_a, end=' ')
for i in range(1, n):
	cur_a = b[i] + cur_max
	cur_max = max(cur_a, cur_max)
	print(cur_a, end=' ')


n = int(input())
x = [int(i) for i in input().split()]
l = []
l.append(x[0])
q = x[0]
for i in range(1, n):
	l.append(q + x[i])
	if q + x[i] > q:
		q = x[i] + q
print(*l)


n = int(input())
a = list(map(int, input().split()))
b = []
s = 0
for i in range(len(a)):
	if a[i] < 0:
		k = s
		s += a[i]
		print(s, end=' ')
		s = k
	else:
		s += a[i]
		print(s, end=' ')


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

def L():
	return list(map(int, input().split()))

def In():
	return map(int, input().split())

def I():
	return int(input())
P = 1000000007

def main():
	n = I()
	arr = L()
	lis = []
	mx = 0
	for i in range(n):
		v = mx + arr[i]
		lis.append(v)
		mx = max(lis[i], mx)
	print(*lis)
main()


n = int(input())
b = list(map(int, input().split()))
aux = b[0]
print(b[0], end=' ')
for i in range(1, n):
	print(aux + b[i], end=' ')
	aux = max(aux, aux + b[i])
print()


z = input
mod = 10 ** 9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)
n = int(z())
l = list(map(int, z().split()))
m = 0
for i in range(n):
	l[i] += m
	m = max(m, l[i])
print(*l)


n = int(input())
l = list(map(int, input().split()))
temp = 0
a = [l[0]]
print(l[0], end=' ')
for i in range(1, n):
	a.append(l[i] + max(temp, a[i - 1]))
	print(a[i], end=' ')
	temp = max(temp, a[i - 1])


n = int(input())
l = list(map(int, input().split()))
m = 0
for x in l:
	print(x + m, end=' ')
	m += max(0, x)


n = int(input())
m = list(map(int, input().split()))
a = []
mx = 0
for i in range(n):
	a.append(m[i] + mx)
	if m[i] + mx > mx:
		mx = m[i] + mx
print(*a)


t = int(input())
b = list(input().split())
a = [b[0], str(int(b[0]) + int(b[1]))]
x = [0, int(b[0])]
for i in range(2, t):
	x.append(max(x[i - 1], int(a[i - 1])))
	a.append(str(int(b[i]) + x[i]))
print(' '.join(a))