The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups.

Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime.

If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated.

Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated.


-----Input-----

The first line of input will contain an integer n (1 ≤ n ≤ 10^5), the number of events. The next line will contain n space-separated integers.

If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time.


-----Output-----

Print a single integer, the number of crimes which will go untreated.


-----Examples-----
Input
3
-1 -1 1

Output
2

Input
8
1 -1 1 -1 -1 1 1 1

Output
1

Input
11
-1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1

Output
8



-----Note-----

Lets consider the second example:  Firstly one person is hired.  Then crime appears, the last hired person will investigate this crime.  One more person is hired.  One more crime appears, the last hired person will investigate this crime.  Crime appears. There is no free policeman at the time, so this crime will go untreated.  One more person is hired.  One more person is hired.  One more person is hired. 

The answer is one, as one crime (on step 5) will go untreated.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
import sys
n = int(sys.stdin.readline())
instr = sys.stdin.readline().split()
count = 0
s = 0
for c in instr:
	if int(c) > 0:
		s += int(c)
	elif int(c) < 0 and s == 0:
		count += 1
	else:
		s += int(c)
print(count)


repetition = int(input())
crimes_hiring = list(map(int, input().split()))
recruits = 0
counter = 0
for i in range(repetition):
	recruits = recruits + crimes_hiring[i]
	if recruits < 0:
		counter = counter + 1
		recruits = 0
print(counter)


n = int(input())
s = 0
k = 0
a = [int(n) for n in input().split(' ')]
for i in range(n):
	if s + a[i] < 0:
		k += 1
		s = 0
	else:
		s += a[i]
print(k)


n = int(input())
array = list(map(int, input().split()))
c = 0
check = 0
for i in array:
	if i == -1:
		if check == 0:
			c = c + 1
		else:
			check = check + i
	if i != -1:
		check = check + i
print(c)


num_events = int(input())
num_list = [int(i) for i in input().split()]
available_police = 0
untreated_crime = 0
for i in num_list:
	if i > 0:
		available_police += i
	elif available_police - 1 >= 0:
		available_police -= 1
	else:
		untreated_crime += 1
print(untreated_crime)


off = 0
ans = 0
(n, l) = (int(input()), list(map(int, input().split())))
for i in range(n):
	num = l[i]
	if num == -1 and off == 0:
		ans += 1
	elif num != -1:
		off += num
	elif num == -1 and off != 0:
		off -= 1
print(ans)


a = int(input())
b = list(map(int, input().split()))
p = 0
coun = 0
for i in b:
	if i > 0:
		p += i
	elif i < 0 and p < 1:
		coun += 1
	elif i < 0 and p >= 1:
		p -= 1
print(coun)


n = int(input())
h = list(map(int, input().split()))
p = 0
a = 0
for e in h:
	if e == -1:
		if p > 0:
			p -= 1
		else:
			a += 1
	else:
		p += e
print(a)


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


n = int(input())
cases = [int(x) for x in input().split()]
policemen = 0
unsolved = 0
for c in cases:
	if c == -1:
		if policemen == 0:
			unsolved += 1
		else:
			policemen -= 1
	else:
		policemen += c
print(unsolved)


n = int(input())
events = list(map(int, input().split()))
p = 0
u = 0
for i in events:
	if i != -1:
		p += i
	elif p == 0:
		u += 1
	else:
		p -= 1
print(u)


a = int(input())
lst = list(map(int, input().split()))
result = 0
polic = 0
i = 0
while i < len(lst):
	if lst[i] != -1:
		polic += lst[i]
	if lst[i] == -1 and polic == 0:
		result += 1
	if lst[i] == -1 and polic != 0:
		polic -= 1
	i += 1
print(result)


input()
a = list(map(int, input().split()))
b = 0
rec = 0
for i in a:
	if i == -1:
		if rec == 0:
			b -= 1
		else:
			rec -= 1
	else:
		rec += i
print(-b)


n = int(input())
d = list(map(int, input().split()))
pol = 0
c = 0
for i in d:
	if i == -1:
		pol -= 1
		if pol == -1:
			pol = 0
			c += 1
	else:
		pol += i
print(c)


n = int(input())
events = map(int, input().split())
officers = 0
crimes = 0
for event in events:
	if event != -1:
		officers += event
	elif officers > 0:
		officers -= 1
	else:
		crimes += 1
print(crimes)


m = int(input())
off = 0
cases = 0
l = [int(i) for i in input().split(' ')]
for j in l:
	if j > 0:
		off = off + j
	elif off < 1:
		cases = cases + 1
	else:
		off = off - 1
print(cases)


size = int(input())
crime_hirings = list(map(int, input().split()))
hirings = 0
untreated_crimes = 0
for i in range(len(crime_hirings)):
	if crime_hirings[i] > 0:
		hirings = hirings + crime_hirings[i]
	elif crime_hirings[i] < 0 and hirings > 0:
		hirings = hirings - 1
	else:
		untreated_crimes = untreated_crimes + 1
print(untreated_crimes)


n = int(input())
a = map(int, input().split())
a = list(a)
freePolice = 0
unsolvedCrime = 0
for i in range(n):
	if a[i] > 0:
		freePolice = freePolice + a[i]
		if unsolvedCrime > 0:
			unsolvedCrime = unsolvedCrime
	if a[i] < 0:
		if freePolice <= 0:
			unsolvedCrime = unsolvedCrime + 1
		elif freePolice > 0:
			freePolice = freePolice - 1
print(unsolvedCrime)


n = int(input())
str = input()
arr = str.split()
freeCops = 0
uninvestigatedCrimes = 0
for i in range(n):
	if arr[i] == '-1':
		if freeCops > 0:
			freeCops -= 1
		else:
			uninvestigatedCrimes += 1
	else:
		freeCops += int(arr[i])
print(uninvestigatedCrimes)


n = int(input())
list1 = list(map(int, input().split(' ')))
pos = 0
untr = 0
for j in list1:
	if j == -1 and pos <= 0:
		untr += 1
	elif j == -1 and pos > 0:
		pos -= 1
	elif j > -1:
		pos += j
print(untr)


a = 0
b = 0
n = int(input())
l = map(int, input().split())
for i in l:
	if i == -1:
		if b > 0:
			b = b - 1
		else:
			a += 1
	else:
		b = b + i
print(a)


n = int(input())
l = map(int, input().split())
pr = 0
c = 0
for i in l:
	if i > 0:
		pr = pr + i
	elif i < 0:
		if pr > 0:
			pr = pr - 1
		else:
			c += 1
print(c)


n = int(input())
a = list(map(int, input().split()))
b = 0
s = 0
f = 0
h = 0
for i in range(n):
	if a[i] < 0:
		if f > 0:
			f = f + a[i]
		elif f <= 0:
			s = s + a[i]
	elif a[i] > 0:
		f = f + a[i]
print(abs(s))


n = int(input())
event = []
event = event + [int(event) for event in input().split()]
k = 0
ans = 0
for i in event:
	k = k + i
	if k < 0:
		ans = ans + 1
		k = 0
print(ans)


n = input()
l = list(map(int, input().split()))
police = 0
crimes = 0
for i in l:
	if i == -1:
		if police == 0:
			crimes += 1
		else:
			police -= 1
	else:
		police += i
print(crimes)


n = int(input())
x = list(map(int, input().split()))
c1 = c2 = 0
for i in x:
	if i < 0:
		if c1 == 0:
			c2 += abs(i)
		else:
			c1 -= abs(i)
	else:
		c1 += i
print(c2)


n = int(input())
actions = [int(i) for i in input().split()]
un_punished = 0
police = 0
for i in actions:
	if i == -1:
		if police == 0:
			un_punished += 1
		else:
			police -= 1
	else:
		police += i
print(un_punished)


n = int(input())
c = list(map(int, input().split()))
ho = uc = 0
for i in c:
	if i > 0:
		ho += i
		continue
	if ho > 0 and i < 0:
		ho -= 1
		continue
	if i < 0:
		uc += 1
print(uc)


n = int(input())
l = list(map(int, input().split()))
(t, a) = (0, 0)
for i in l:
	if i == -1:
		if not t:
			a += 1
		else:
			t -= 1
	else:
		t += i
print(a)


inp = int(input())
n = list(map(int, input().split()))
crime = 0
hire = 0
for x in range(inp):
	crime = crime + n[x]
	if crime < 0:
		hire += 1
		crime = 0
print(hire)


n = int(input())
num = input()
list = [int(i) for i in num.split()]
f = 0
w = 0
for i in list:
	if i > 0:
		f += i
	elif f > 0:
		f -= 1
	else:
		w += 1
print(w)


from sys import stdin, exit
stdin.readline()
events = list(map(int, stdin.readline().rstrip().split(' ')))
cops = 0
bads = 0
for e in events:
	if e == -1:
		if cops > 0:
			cops -= 1
		else:
			bads += 1
	else:
		cops += e
print(bads)


n = int(input())
result = 0
count = 0
for i in (int(i) for i in input().split()):
	if i == -1 and count == 0:
		result += 1
	else:
		count += i
print(result)


n = int(input())
l = [int(i) for i in input().split()]
a = 0
b = 0
for i in range(n):
	if l[i] > 0:
		a += int(l[i])
	elif a > 0:
		a -= 1
	else:
		b += 1
print(b)


n = int(input())
array = [int(x) for x in input().split()]
officers_ready = 0
answer = 0
for x in array:
	if x == -1:
		if officers_ready == 0:
			answer += 1
		else:
			officers_ready -= 1
	else:
		officers_ready += x
print(answer)


def main():
	t = int(input())
	n = list(map(int, input().split()))
	police = 0
	ans = 0
	for i in n:
		if i == -1:
			if police < 1:
				ans += 1
			else:
				police -= 1
		else:
			police += i
	print(ans)
main()


i = int(input())
x = y = t = int(0)
arr = list(map(int, input().split()))
if i == len(arr):
	y = 1
	for j in arr:
		if j > 0 and j <= 10:
			t = t + j
		elif j == -1:
			if t == 0:
				x = x + j
			else:
				t = t + j
		else:
			y = 0
if y == 1:
	print(-x)


a = int(input())
k = []
k = list(map(int, input().split()))
q = 0
pol = 0
pre = 0
ner = 0
for i in k:
	if i > 0:
		pol += i
	elif pol > 0:
		pol -= 1
	else:
		ner += 1
print(ner)


def pr(events):
	untreatedCrimes = 0
	policeAvailable = 0
	for event in events:
		if event == -1:
			if policeAvailable > 0:
				policeAvailable -= 1
			else:
				untreatedCrimes += 1
		else:
			policeAvailable += event
	return untreatedCrimes
n = int(input())
events = map(int, input().split(' '))
print(pr(events))


no_events = int(input())
events = input().split(' ')
cops_avail = 0
crimes_unnoticed = 0
for event in events:
	if event == '-1':
		if cops_avail == 0:
			crimes_unnoticed += 1
		else:
			cops_avail -= 1
	else:
		cops_avail += int(event)
print(crimes_unnoticed)


n = int(input())
arr = list(map(int, input().split()))
rec = 0
count = 0
for i in arr:
	if i > 0:
		rec += i
	elif rec > 0:
		rec -= 1
	elif rec <= 0:
		count += 1
print(count)


n = int(input())
m = input().split()
k = 0
it = 0
for i in range(n):
	if m[i] == '-1':
		if k > 0:
			k -= 1
		else:
			it += 1
	else:
		k += int(m[i])
print(it)


n = int(input())
crime = 0
rec = 0
events = input().split(' ')
for event in events:
	if int(event) == -1 and rec == 0:
		crime += 1
	elif int(event) == -1 and rec > 0:
		rec -= 1
	else:
		rec += int(event)
print(crime)


n = int(input())
l = list(map(int, input().split()))
c = 0
nc = 0
for i in range(n):
	if nc == 0 and l[i] == -1:
		c += 1
	elif l[i] == -1 and nc != 0:
		nc -= 1
	elif l[i] != -1 and nc != 0:
		nc += l[i]
	else:
		nc += l[i]
print(c)


n = int(input())
l = list(map(int, input().split()))
npolice = 0
ncrime = 0
for i in l:
	if i == -1:
		if npolice > 0:
			npolice -= 1
		else:
			ncrime += 1
	else:
		npolice += i
print(ncrime)


n = int(input())
cN = 0
p = 0
inp = list(map(int, input().split()))
x = []
for i in range(0, n):
	x.insert(i, inp[i])
	if x[i] < 0:
		if p > 0:
			p = p - 1
		else:
			cN = cN + 1
	else:
		p = p + x[i]
print(cN)


n = int(input())
a = [int(i) for i in input().split()]
cnt = 0
cntpols = 0
for i in range(len(a)):
	if a[i] == -1:
		if cntpols == 0:
			cnt += 1
		else:
			cntpols -= 1
	else:
		cntpols += a[i]
print(cnt)


k = input()
n = list(map(int, input().split()))
s = 0
x = 0
for i in range(len(n)):
	if n[i] <= 10:
		if n[i] >= 0:
			s = s + n[i]
		if n[i] == -1:
			s = s - 1
			if s < 0:
				x = x + 1
				s = 0
print(x)


n = int(input())
tab = list(map(int, input().split()))
untreated = 0
psiarnia = 0
for i in tab:
	if i == -1:
		if psiarnia == 0:
			untreated += 1
		else:
			psiarnia -= 1
	else:
		psiarnia += i
print(untreated)


import sys

def get():
	return int(sys.stdin.readline().strip())

def getli():
	return list(map(int, sys.stdin.readline().strip().split()))
n = get()
A = getli()[::-1]
k = 0
for i in A:
	k = min(0, k + i)
print(abs(k))


def Police():
	n = int(input())
	a = list(map(int, input().split()))
	policemen = 0
	untreated = 0
	for num in a:
		if num == -1:
			if policemen == 0:
				untreated += 1
			else:
				policemen -= 1
		else:
			policemen += num
	print(untreated)
Police()


m = eval(input())
inp = list(map(int, input().split()))
count = 0
p = 0
for i in range(0, len(inp), 1):
	if inp[i] > 0:
		p = p + inp[i]
	elif inp[i] == -1:
		if p >= 1:
			p = p - 1
		else:
			count += 1
print(count)


n = int(input())
l = [int(i) for i in input().split()]
g = 0
br = 0
for i in l:
	if i > 0:
		br += i
	if i < 0 and br == 0:
		g += 1
	if i < 0 and br > 0:
		br -= 1
print(g)


n = int(input())
events = [int(x) for x in input().split()]
free_recruits = 0
ignored_crimes = 0
for x in events:
	if x == -1:
		if free_recruits > 0:
			free_recruits -= 1
		else:
			ignored_crimes += 1
	else:
		free_recruits = free_recruits + x
print(ignored_crimes)


input()
res = 0
p = 0
for i in input().split():
	i = int(i)
	if i > 0:
		p += i
	elif p == 0:
		res += 1
	else:
		p -= 1
print(res)


n = int(input())
a = list(map(int, input().split()))
c = 0
k = 0
s = 0
for i in range(0, len(a)):
	if a[i] >= 0:
		s = s + a[i]
	else:
		c = s + a[i]
		if c < 0:
			k = k + 1
		else:
			s = s - 1
print(k)


n = int(input())
s = list(map(int, input().split()))
p = 0
k = 0
for i in s:
	if i > 0:
		p += i
	if i < 0:
		if p == 0:
			k += 1
		else:
			p -= 1
print(k)


n = int(input())
row = input().split()
policia = 0
criminosos = 0
for i in range(n):
	if int(row[i]) == -1:
		if policia > 0:
			policia = policia - 1
		else:
			criminosos = criminosos + 1
	else:
		policia = policia + int(row[i])
print(criminosos)


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


n = int(input())
c = list(map(int, input().split()))
avail = 0
un = 0
for i in c:
	if i == -1:
		if avail > 0:
			avail = avail - 1
		else:
			un = un + 1
	elif i > 0:
		avail = avail + i
print(un)


input()
crime = int(0)
policies = int(0)
actions = list(map(int, input().split()))
for action in actions:
	if action > int(0):
		policies += action
	elif policies > int(0):
		policies -= 1
	else:
		crime += 1
print(crime)


n = int(input())
x = list(map(int, input().split()))
(hired, untrated) = (0, 0)
for i in x:
	if i > 0:
		hired += i
		continue
	if i < 0 and hired > 0:
		hired -= 1
		continue
	if i < 0:
		untrated += 1
print(untrated)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
BUFSIZE = 8192
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 main():
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	c = 0
	for i in range(n):
		if a[i] > 0:
			b.append(a[i])
		elif len(b) == 0:
			c += 1
		else:
			d = b.pop()
			d -= 1
			if d > 0:
				b.append(d)
	print(c)
main()


n = int(input())
l = list(map(int, input().split()))
(p, c) = (0, 0)
for i in l:
	if i > 0:
		p += i
	elif p > 0:
		p -= 1
	else:
		c += 1
print(c)


a = int(input())
b = [int(i) for i in input().split()]
csum = 0
sum = 0
for i in range(0, len(b)):
	if b[i] > 0:
		sum = sum + b[i]
	elif b[i] < 0:
		csum = csum + 1
		if sum > 0:
			csum = csum - 1
			sum = sum - 1
		else:
			continue
print(csum)


n = int(input())
(p, r) = (0, 0)
for i in list(map(int, input().split())):
	if i == -1 and p == 0:
		r += 1
		continue
	else:
		p += i
print(r)


n = int(input())
list1 = list(map(int, input().split(' ')))
cou = 0
ans = 0
for i in list1:
	if i == -1:
		if cou > 0:
			cou -= 1
		else:
			ans += 1
	else:
		cou += i
print(ans)


n = int(input())
a = list(map(int, input().split()))
(ans, occ) = (0, 0)
for i in range(len(a)):
	if a[i] > 0:
		ans += a[i]
	elif ans > 0:
		ans -= 1
	else:
		occ += 1
print(occ)


size = int(input())
li = list(map(int, input().split()))
police = 0
crimes = 0
for i in li:
	if i > 0:
		police += i
	elif i == -1:
		if police > 0:
			police -= 1
		else:
			crimes += 1
print(crimes)


n = int(input())
events = [int(x) for x in input().split()]
cop_count = 0
crime_count = 0
for event in events:
	if event < 0 and cop_count == 0:
		crime_count += 1
	else:
		cop_count += event
print(crime_count)


test = int(input())
li = list(map(int, input().split()))
c = u = 0
for i in li:
	if i >= 1:
		c += i
	elif c > 0:
		c -= 1
	else:
		u += 1
print(u)


_ = input()
arr = map(int, input().split())
officer_free = 0
untreated = 0
for i in arr:
	if i == -1:
		if not officer_free:
			untreated += 1
		else:
			officer_free -= 1
	else:
		officer_free += i
print(untreated)


n = int(input())
lis = list(map(int, input().split()))
untreated = 0
police = 0
for i in lis:
	if i >= 0 or (i < 0 and police > 0):
		police = police + i
	else:
		untreated = untreated + 1
print(untreated)


n = int(input())
l = list(map(int, input().split()))
man = 0
crime = 0
for i in range(n):
	x = l[i]
	if x > 0:
		man += x
	elif x < 0:
		man += x
	if man < 0:
		crime += 1
		man = 0
print(crime)


n = int(input())
x = input().split()
m = []
for i in x:
	m.append(int(i))
s = 0
c = 0
for j in m:
	if j > 0:
		s += j
	elif s > 0:
		s += j
	else:
		c += 1
print(c)


s = int(input())
x = [int(x) for x in input().split()]
p = 0
r = 0
t = 0
for i in x:
	if i == -1:
		if p > 0:
			p -= 1
		else:
			t += 1
	else:
		p += i
print(t)


def solve(arr):
	cop = 0
	counter = 0
	for i in range(len(arr)):
		if arr[i] != '-1':
			cop += int(arr[i])
		elif cop == 0:
			counter += 1
		else:
			cop -= 1
	print(counter)
h = input()
arr = input().split()
solve(arr)


n = int(input())
l = list(map(int, input().split()))
crimes = 0
hire = 0
for x in l:
	if x > 0:
		hire += x
	if x < 0:
		crimes += 1
	if x < 0 and hire > 0:
		hire -= 1
		crimes -= 1
print(crimes)


n = int(input())
(count, sum) = (0, 0)
for i in map(int, input().split()):
	sum += i
	if sum == -1:
		count += 1
		sum = 0
print(count)


n = int(input())
s = [int(a) for a in input().split()]
i = 0
po = 0
ne = 0
while i < len(s):
	if s[i] > 0:
		po = po + s[i]
		i = i + 1
	elif po > 0:
		ne = ne
		po = po - 1
		i = i + 1
	else:
		ne = ne + 1
		i = i + 1
print(ne)


n = int(input())
arr = list(map(int, input().split()))
check = 0
totalPolice = 0
police = 0
for i in range(len(arr)):
	if arr[i] >= 1:
		totalPolice += arr[i]
	elif totalPolice > 0 and arr[i] == -1:
		totalPolice += arr[i]
	elif totalPolice == 0 and arr[i] == -1:
		check += 1
print(check)


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


n = int(input())
a = [int(x) for x in input().split()]
s = 0
t = 0
for i in range(n):
	if a[i] < 0:
		s = s - 1
	elif s >= 0:
		s = s + a[i]
	else:
		s = a[i]
	if s < 0:
		t = t - 1
print(-t)


t = int(input())
l = list(map(int, input().split()))
cur = 0
count = 0
for i in range(t):
	if l[i] > 0:
		cur += l[i]
	elif cur > 0:
		cur -= 1
	else:
		count += 1
print(count)


n = int(input())
e = [int(num) for num in input().split()]
(rec, ans) = (0, 0)
for i in e:
	if i != -1:
		rec += i
	elif rec > 0:
		rec -= 1
	else:
		ans += 1
print(ans)


length = int(input(''))
line = [int(x) for x in input('').split()]
officers = 0
ans = 0
for i in range(length):
	if line[i] >= 0:
		officers += line[i]
	elif officers > 0:
		officers -= 1
	else:
		ans += 1
print(ans)


n = int(input())
li = [int(x) for x in input().split()]
count = 0
pos = 0
for x in li:
	if x == -1:
		pos = pos + x
		if pos < 0:
			pos = 0
			count = count + 1
	else:
		pos = pos + x
print(count)


a = int(input())
t = list(map(int, input().split()))
p = 0
c = 0
for k in range(a):
	if t[k] > 0:
		p += t[k]
	elif t[k] == -1:
		if p > 0:
			p -= 1
		else:
			c += 1
print(c)


n = int(input())
s = list(map(int, input().split()))
p = 0
cnt = 0
for i in range(len(s)):
	if s[i] == -1:
		if p > 0:
			p -= 1
		else:
			cnt += 1
	else:
		p += s[i]
print(cnt)


n = int(input())
li = input().split()
crime = 0
police = 0
for i in range(n):
	li[i] = int(li[i])
for j in range(n):
	if li[j] == -1 and police == 0:
		crime += 1
	elif li[j] == -1 and police > 0:
		police -= 1
	else:
		police += li[j]
print(crime)


n = int(input())
l = [int(ele) for ele in input().split()]
noc = 0
nop = 0
for e in l:
	if e > 0:
		nop += e
	elif nop == 0 or e < 0:
		noc += 1
	if nop != 0 and e < 0:
		nop -= 1
		noc -= 1
print(noc)


n = int(input())
events = [int(x) for x in input().split()]
policemen = 0
unsolved = 0
for i in range(n):
	if events[i] < 0:
		policemen -= 1
		unsolved += 1 if policemen < 0 else 0
	else:
		policemen = events[i] + (0 if policemen < 0 else policemen)
print(unsolved)


n = int(input())
a_list = [int(x) for x in input().split()]
count = 0
ans = 0
for c in a_list:
	count += c
	if count < 0:
		ans += count
		count = 0
print(str(ans * -1))


n = int(input())
a = list(map(int, input().split()))
p = 0
k = 0
for i in a:
	p = p + i
	if p < 0:
		k = k + 1
		p = 0
print(k)


n = int(input())
d = list(map(int, input().split()))
untreated = 0
police = 0
for i in range(n):
	if d[i] == -1:
		if police == 0:
			untreated += 1
		else:
			police -= 1
	else:
		police += d[i]
print(untreated)


n = int(input())
s = input()
a = list(s.split())
i = 0
while i < n:
	a[i] = int(a[i])
	i += 1
ans = 0
i = 0
s = 0
while i < n:
	if a[i] >= 0:
		s += a[i]
	elif s > 0:
		s -= 1
	else:
		ans += 1
	i += 1
print(ans)


input()
r = 0
a = list(map(int, input().split()))
for i in a[::-1]:
	r = min(0, r + i)
print(-r)


n = int(input())
list1 = list(map(int, input().split(' ')))
count = 0
count1 = 0
for i in list1:
	if i == -1:
		if count == 0:
			count1 = count1 + 1
		else:
			count = count - 1
	else:
		count = count + i
print(count1)


n = int(input())
l = list(input().split())
l = [int(i) for i in l]
answer = 0
sum = 0
for i in l:
	sum += i
	if sum < 0:
		answer += 1
		sum = 0
	else:
		continue
print(answer)


n = int(input())
l = list(map(int, input().split()))
p = []
c = []
count = 0
for i in l:
	if i == -1 and len(p) == 0:
		count += 1
	elif i == -1 and len(p) > 0:
		k = p.pop()
		k = k - 1
		if k > 0:
			p.append(k)
	else:
		p.append(i)
print(count)


n = int(input())
inp = list(map(int, input().split()))
nr = uc = 0
for i in range(n):
	if inp[i] > 0:
		nr += inp[i]
	elif inp[i] + nr >= 0:
		nr += inp[i]
	else:
		uc += 1
print(uc)


n = int(input())
event = [int(x) for x in input().split()]
crime = 0
untreat = 0
for i in range(n):
	crime += event[i]
	if crime < 0:
		untreat += 1
		crime = 0
print(untreat)


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


n = int(input())
lst = list(map(int, input().split()))
a = 0
count = 0
for i in range(len(lst)):
	if lst[i] < 0 and count > 0:
		count -= 1
	elif lst[i] < 0 and count <= 0:
		a += 1
	elif lst[i] > 0:
		count += lst[i]
print(a)


n = int(input())
lt = [int(x) for x in input().split()]
s = x = 0
for i in range(n):
	if lt[i] != -1:
		s += lt[i]
	elif s >= 1:
		s -= 1
	else:
		x += 1
print(x)


n = int(input())
x = input().split()
s = 0
c = 0
for i in range(n):
	s = s + int(x[i])
	if s < 0:
		c = c + 1
		s = 0
print(c)


p = int(input())
(busyNt, op) = (0, 0)
exp = [int(n) for n in input().split()]
for i in exp:
	if i >= 1:
		busyNt += i
	elif busyNt >= 1:
		busyNt += i
	else:
		op += 1
print(op)


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


n = int(input())
arr = list(map(int, input().split()))
cops = 0
thief = 0
for i in arr:
	if i < 0 and cops == 0:
		thief += 1
	elif i > 0:
		cops += i
	elif i < 0 and cops > 0:
		cops -= 1
print(thief)


n = int(input())
l = list(map(int, input().split()))
mi = 0
s = 0
for i in l:
	s += i
	mi = min(mi, s)
print(abs(mi))


a = int(input())
b = list(map(int, input().split()))
ut = y = 0
for i in b:
	if i < 0 and y == 0:
		ut += 1
	elif i < 0 and y != 0:
		y += i
	else:
		x = i
		y += x
print(ut)


n = int(input())
arr = list(map(int, input().split()))
police = 0
crimes = 0
for i in arr:
	if i == -1:
		if police == 0:
			crimes += 1
		elif police > 0:
			police -= 1
	elif i > 0:
		police += i
print(crimes)


n = int(input())
events = [int(x) for x in input().split()]
ctr = 0
st = 0
for e in events:
	if e < 0:
		if st < 1:
			ctr += 1
		else:
			st -= 1
	else:
		st += e
print(ctr)


n = int(input())
arr = [int(elem) for elem in input().split()]
(crimes, policemens) = (0, 0)
for i in range(n):
	if arr[i] == -1:
		if policemens == 0:
			crimes += 1
		else:
			policemens -= 1
	else:
		policemens += arr[i]
print(crimes)


n = int(input())
ls = list(map(int, input().split()))
cops = 0
c = 0
for i in ls:
	if i > 0:
		cops += i
	elif cops > 0:
		cops -= 1
	else:
		c += 1
print(c)


n = int(input())
a = list(map(int, input().split()))
c = 0
d = 0
for i in a:
	if i == -1 and d != 0:
		d = d - 1
	elif i == -1 and d == 0:
		c = c + i
	elif i != -1:
		d = d + i
print(-c)


n = int(input())
a = list(map(int, input().split()))
mc = 0
c = 0
for i in a:
	c += i
	mc = min(c, mc)
print(abs(mc))


n = int(input())
a = list(map(int, input().split()))
p = 0
u = 0
for i in range(n):
	if int(a[i]) == -1 and p == 0:
		u += 1
	elif int(a[i]) > 0:
		p = p + int(a[i])
	elif int(a[i]) == -1 and p > 0:
		p = p - 1
print(u)


def go(ls):
	s = []
	count = 0
	for i in ls:
		if i == -1:
			if s:
				s[-1] -= 1
				if s[-1] == 0:
					s.pop()
			else:
				count += 1
		else:
			s += (i,)
	return count
t = input()
ls = list(map(int, input().split()))
print(go(ls))


n = int(input())
p = [int(x) for x in input().split()]
s = 0
t = 0
for i in range(0, n):
	if p[i] == -1:
		if s == 0:
			t += 1
		else:
			s -= 1
	else:
		s += p[i]
print(t)


n = int(input())
x = list(map(int, input().split()))
cr = 0
p = 0
for i in x:
	if i > 0:
		p += i
	elif i < 0 and p > 0:
		p -= 1
	elif i < 0:
		cr += 1
print(cr)


n = int(input())
st = [int(x) for x in input().split()]
numOf = 0
result = 0
for i in range(len(st)):
	if st[i] == -1 and numOf == 0:
		result += 1
	elif st[i] >= 1:
		numOf += st[i]
	else:
		numOf -= 1
print(result)


n = int(input())
l = list(map(int, input().split()))
untreated = 0
currentoff = 0
for ele in l:
	if ele > 0:
		currentoff += ele
	elif currentoff == 0:
		untreated += 1
	else:
		currentoff -= 1
print(untreated)


n = int(input())
lis = input().split()
cop = 0
crime = 0
i = 0
while i <= n - 1:
	if lis[i] == '-1':
		if cop >= 1:
			cop -= 1
		else:
			crime += 1
	else:
		cop += int(lis[i])
	i += 1
print(crime)


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 scanf(datatype=str):
	return datatype(sys.stdin.readline().rstrip())

def printf(answer=''):
	return sys.stdout.write(str(answer) + '\n')

def prints(answer):
	return sys.stdout.write(str(answer) + ' ')

def map_input(datatype=str):
	return map(datatype, sys.stdin.readline().split())

def list_input(datatype=str):
	return list(map(datatype, sys.stdin.readline().split()))

def testcase(number: int, solve_function):
	for _ in range(number):
		printf(solve_function())

def solve():
	n = scanf(int)
	arr = list_input(int)
	crimes = police = 0
	ans = 0
	for i in arr:
		if i < 0:
			if police > 0:
				police -= 1
			else:
				crimes += 1
		else:
			ans += crimes
			crimes = 0
			police += i
	if crimes:
		ans += crimes
	return ans
printf(solve())


n = int(input())
events = input().split()
untreated = 0
officers = 0
for i in range(len(events)):
	events[i] = int(events[i])
	if events[i] == -1:
		if officers > 0:
			officers -= 1
		else:
			untreated += 1
	else:
		officers += events[i]
print(untreated)


n = int(input().strip())
p = list(map(int, input().split()))
zero1 = 0
zero2 = 0
for i in p:
	if i < 0:
		if zero2 > 0:
			zero2 -= 1
		else:
			zero1 += 1
	else:
		zero2 += i
print(zero1)


n = int(input())
arr = [int(i) for i in input().split(' ')]
(res, sum) = (0, 0)
for i in arr:
	if i > 0:
		sum += i
	elif i < 0:
		if sum > 0:
			sum -= 1
		elif sum == 0:
			res += 1
print(res)


n = int(input())
l = list(map(int, input().split()))
r = 0
s = 0
for i in range(n):
	if l[i] < 0 and s > 0:
		s = s - 1
	elif l[i] < 0 and s == 0:
		r = r + 1
	else:
		s = s + l[i]
print(r)


input()
z = list(map(int, input().split()))
cnt = 0
recruit = 0
for i in z:
	if i < 0 and recruit == 0:
		cnt += 1
	elif i < 0 and recruit > 0:
		recruit -= 1
		if recruit <= 0:
			recruit = 0
	else:
		recruit += i
print(cnt)


n = int(input())
ai = list(map(int, input().split()))
r = 0
for i in ai[::-1]:
	r = min(0, r + i)
print(-r)


n = int(input())
stack = []
count = 0
lst = list(map(int, input().split()))
for i in lst:
	if i > 0:
		stack.extend([1] * i)
	else:
		try:
			stack.pop()
		except:
			count += 1
print(count)


n = input()
myList = list(map(int, input().split()))
crimes = 0
officers = 0
for elem in myList:
	if elem == -1:
		if officers == 0:
			crimes += 1
		else:
			officers -= 1
	else:
		officers += elem
print(crimes)


n = int(input())
pos = 0
min = 0
x = list(input().split())
if '-1' in x:
	for i in range(n - 1, -1, -1):
		if x[i] == '-1':
			v = i + 1
			break
		else:
			continue
	for i in range(v):
		if x[i] == '-1' and pos == 0:
			min += 1
		elif x[i] == '-1' and pos > 0:
			pos -= 1
		else:
			pos += int(x[i])
	print(min)
else:
	print('0')


police = 0
n = input('')
line = input('')
line = line.split(' ')
ans = 0
for event in line:
	if int(event) == -1:
		if police == 0:
			ans += 1
		else:
			police -= 1
	else:
		police += int(event)
print(ans)


n = int(input())
e = map(int, input().split())
count = 0
mans = 0
for i in e:
	if i > 0:
		mans += i
	elif mans > 0:
		mans -= 1
	else:
		count += 1
print(count)


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


def to_list(s):
	return list(map(lambda x: int(x), s.split(' ')))

def solve(a):
	sum_ = 0
	count = 0
	for i in range(len(a)):
		if a[i] == -1:
			if sum_ == 0:
				count += 1
			else:
				sum_ -= 1
		else:
			sum_ += a[i]
	return str(count)
n = int(input())
a = to_list(input())
print(solve(a))


n = int(input())
lst = list(map(int, input().strip().split()))[:n]
hr = 0
cr = 0
for i in lst:
	if i == -1 and hr == 0:
		cr += 1
	elif i == -1 and hr != 0:
		hr -= 1
	elif i != -1:
		hr += i
print(cr)


n = int(input())
string = str(input())
arr = string.split()
h = 0
crime = 0
for i in range(len(arr)):
	if arr[i] != '-1':
		h += int(arr[i])
	if arr[i] == '-1':
		h = h - 1
		if h < 0:
			crime += 1
			h = 0
print(crime)


import sys
n = int(sys.stdin.readline().split()[0])
events = [int(i) for i in sys.stdin.readline().split()]
policeman_count = 0
unrelease_count = 0
for event in events:
	if event == -1:
		if policeman_count > 0:
			policeman_count -= 1
		else:
			unrelease_count += 1
	elif event > 0:
		policeman_count += event
print(unrelease_count)


n = int(input())
occ = list(map(int, input().split()))
(c, cr) = (0, 0)
for i in range(len(occ)):
	if c == 0 and occ[i] < 0:
		cr = cr + 1
	elif c >= 0 and occ[i] > 0:
		c = c + occ[i]
	elif c > 0 and occ[i] < 0:
		c = c + occ[i]
print(cr)


events = int(input())
what = [int(x) for x in input().split()]
untreated = 0
crime = 0
officers = 0
for i in what:
	if i == -1:
		crime += 1
		officers -= 1
	else:
		officers += i
	if officers < 0:
		untreated += 1
		officers = 0
print(untreated)


n = input()
l = input().split(' ')
for i in range(len(l)):
	l[i] = int(l[i])
c = 0
t = 0
for i in l:
	if i != -1:
		t = t + i
	elif t > 0:
		t = t - 1
	else:
		c = c + 1
print(c)


n = int(input())
a = list(map(int, input().split()))
b = 0
p = 0
for x in range(n):
	if a[x] < 0 and b > 0:
		b += a[x]
	elif a[x] < 0 and b == 0:
		p -= a[x]
	elif a[x] > 0:
		b += a[x]
print(p)


n = int(input())
n1 = list(map(int, input().split()))
s = 0
b = 0
for i in n1:
	if i != -1:
		s = s + i
	elif s != 0:
		s = s - 1
		b = b + 1
print(n1.count(-1) - b)


n = int(input())
event = list(map(int, input().split()))
hold = 0
unt = 0
for i in event:
	if i > 0:
		hold += i
	elif hold > 0:
		hold -= 1
	else:
		unt += 1
print(unt)


from sys import stdin
_ = stdin.readline()
s = stdin.readline()[:-1].split(' ')
n = 0
p = 0
for i in s:
	if i == '-1':
		if p > 0:
			p -= 1
		else:
			n += 1
	else:
		p += int(i) if int(i) <= 10 else 10
print(n)


n = int(input())
l = input().split()
policecnt = 0
lis = []
for i in range(0, n):
	if int(l[i]) == -1:
		if policecnt > 0:
			policecnt -= 1
			continue
		else:
			lis.append(l[i])
	elif int(l[i]) > 0:
		policecnt += int(l[i])
print(len(lis))


input()
array_input = input().split(' ')
counter_of_coops = 0
crimes_not_resolve = 0
for x in array_input:
	value = int(x)
	if value > 0:
		counter_of_coops += value
	elif counter_of_coops > 0:
		temporal = counter_of_coops - abs(value)
		if temporal >= 0:
			counter_of_coops -= abs(value)
		else:
			value += counter_of_coops
			counter_of_coops = 0
			crimes_not_resolve += abs(value)
	else:
		crimes_not_resolve += abs(value)
print(crimes_not_resolve)


input()
events = [int(item) for item in input().split()]
manpower = 0
untreated = 0
for event in events:
	if event > 0:
		manpower += min(10, event)
	elif manpower == 0:
		untreated += 1
	else:
		manpower -= 1
print(untreated)


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


n = int(input())
l = list(map(int, input().split(' ')))
sum = 0
resp = 0
for i in l:
	if i > 0:
		sum += i
	elif sum > 0:
		sum -= 1
	else:
		resp += 1
print(resp)


n = int(input())
lst = list(map(int, input().split()))
pol = 0
res = 0
for i in range(n):
	if lst[i] < 0:
		if lst[i] + pol < 0:
			res += abs(lst[i] + pol)
		else:
			pol -= abs(lst[i])
	else:
		pol += lst[i]
print(res)


n = int(input())
g = 0
ans = 0
for i in input().split():
	if int(i) >= 1:
		g += int(i)
	elif g >= 1:
		g -= 1
	else:
		ans += 1
print(ans)


a = input()
b = input().split()
crimes = 0
polices = 0
for element in b:
	if int(element) > 0:
		polices += int(element)
	if element == '-1':
		if polices == 0:
			crimes += 1
		else:
			polices -= 1
print(crimes)


n = int(input())
ar = [int(i) for i in input().strip().split()]
(police, crimes) = (0, 0)
for i in ar:
	if i > 0:
		police += i
	elif police < 1:
		crimes += 1
	else:
		police -= 1
print(crimes)


n = int(input())
ent = list(map(int, input().split()))
n_pols = 0
resp = 0
for i in ent:
	if i > 0:
		n_pols += i
	elif n_pols > 0:
		n_pols -= 1
	else:
		resp += 1
print(resp)


import sys
from random import choice, randint
inp = sys.stdin.readline
out = sys.stdout.write
flsh = sys.stdout.flush
sys.setrecursionlimit(10 ** 9)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
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 MI():
	return map(int, inp().strip().split())

def LI():
	return list(map(int, inp().strip().split()))

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

def LI_():
	return [int(x) - 1 for x in inp().strip().split()]

def LF():
	return [float(x) for x in inp().strip().split()]

def LS():
	return inp().strip().split()

def I():
	return int(inp().strip())

def F():
	return float(inp().strip())

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

def pf(s):
	return out(s + '\n')

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 main():
	n = I()
	a = LI()
	(c, c1) = (0, 0)
	for i in a:
		if i < 0:
			c1 += 1
			if c > 0:
				c -= 1
				c1 -= 1
		else:
			c += i
	pf(str(c1))
main()


s = int(input())
l = list(map(int, input().split()))
po = 0
s = 0
for i in l:
	if i > 0:
		po += i
	elif po > 0:
		po -= 1
	else:
		s += 1
print(s)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
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
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

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 [l1d(n, val) for j in range(m)]
n = int(data())
arr = l()
(rec, crime) = (0, 0)
for i in arr:
	if i == -1:
		if rec > 0:
			rec -= 1
		else:
			crime += 1
	else:
		rec += i
out(crime)


n = int(input())
num = list(map(int, input().split()))
s = 0
count = 0
for i in num:
	if i > 0:
		s += i
	elif i < 0 and s <= 0:
		count += 1
	elif i < 0:
		s -= 1
print(count)


n = int(input())
l = [int(x) for x in input().split()]
p = 0
c = 0
for x in l:
	if x > 0:
		p += x
	elif p == 0:
		c += 1
	else:
		p -= 1
print(c)


import os
import sys
import math

def comp():
	mystr = sys.stdin.readlines()
	mystr = mystr[1][:-1].split(' ')
	for i in range(len(mystr)):
		mystr[i] = int(mystr[i])
	totalcrime = 0
	totalpolice = 0
	for k in mystr:
		if k != -1:
			totalpolice += k
		elif totalpolice > 0:
			totalpolice -= 1
		else:
			totalcrime += 1
	print(totalcrime)
	return 0
comp()


n = int(input())
li = list(map(int, input().split()))[:n]
sum = 0
count = 0
for i in li:
	c = False
	if sum <= 0 and i == -1:
		count += 1
		c = True
	if not c:
		sum += i
	else:
		sum = 0
print(count)


n = int(input())
a = list(map(int, input().split()))
h = 0
t = 0
for i in a:
	if i > 0:
		h += i
		continue
	if h > 0 and i < 0:
		h -= 1
		continue
	if i < 0:
		t += 1
print(t)


n = input()
events = [int(x) for x in input().split(' ')]
(untreated, hired) = (0, 0)
for x in events:
	if x > 0:
		hired += x
	elif x < 0 and hired > 0:
		hired -= 1
	else:
		untreated += 1
print(untreated)


count = int(input())
mylist = list(map(int, input().split()))
current = 0
answer = 0
for i in range(count):
	value = mylist[i]
	current += value
	if current < 0:
		answer += abs(current)
		current = 0
print(answer)


n = int(input())
s = list(map(int, input().split()))
k = 0
c = 0
for i in s:
	if i > 0:
		k += i
	elif k > 0:
		k -= 1
	else:
		c += 1
print(c)


n = int(input())
entrada = list(map(int, input().split()))
contratados = 0
crimes = 0
for i in entrada:
	if i == -1:
		if contratados > 0:
			contratados -= 1
		else:
			crimes += 1
	else:
		contratados += i
print(crimes)


n = int(input())
police = 0
crimes = 0
for i in input().split():
	i = int(i)
	if i < 0 and police <= 0:
		crimes += 1
	elif i < 0 and police > 0:
		police -= abs(i)
	else:
		police += i
print(crimes)


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


(n, c, b) = (int(input()), 0, 0)
l = list(map(int, input().split()))
for i in l:
	if i == -1:
		if b > 0:
			b -= 1
		else:
			c += 1
	else:
		b += i
print(c)


input()
args = [int(x) for x in input().split(' ')]
police = 0
crime = 0
for a in args:
	if a > 0:
		police += a
	elif a == -1:
		if police > 0:
			police -= 1
		else:
			crime += 1
print(str(crime))


_ = input()
events = [int(x) for x in input().split()]
avail = 0
crimes = 0
for e in events:
	if e == -1:
		if avail > 0:
			avail -= 1
		else:
			crimes += 1
	else:
		avail += e
print(crimes)


n = int(input())
events = list(map(int, input().split()))
police = 0
crimes = 0
for i in events:
	if i > 0:
		police += i
	elif police > 0:
		police -= 1
	else:
		crimes += 1
print(crimes)


events = int(input())
crimes = list(map(int, input().split()))
balance = gluhari = 0
for i in range(len(crimes)):
	balance = balance + crimes[i]
	if balance == -1:
		gluhari = gluhari + 1
		balance = 0
print(gluhari)


n = int(input())
a = [int(x) for x in input().split()]
ans = 0
sum = 0
for i in range(n):
	if a[i] > 0:
		sum += a[i]
	if a[i] == -1:
		if sum == 0:
			ans += 1
		else:
			sum -= 1
print(ans)


po = 0
cr = 0
n = int(input())
x = []
x = input().split()
for i in range(n):
	x[i] = int(x[i])
for i in range(n):
	cr = min(cr + po + x[i], cr)
	po = max(po + x[i], 0)
print(-cr)


n = int(input().strip())
ll = list(map(int, input().split()))
javob = 0
kol = 0
for i in ll:
	if i < 0:
		if kol > 0:
			kol -= 1
		else:
			javob += 1
	else:
		kol += i
print(javob)


n = int(input())
(p, c) = (0, 0)
num = [int(i) for i in input().split()]
for i in num:
	if i > 0:
		p += i
	elif i == -1 and p <= 0:
		c += 1
	else:
		p -= 1
print(c)


noOfEvents = input()
listOfEvents = [int(x) for x in input().split(' ')]
noOfCrimesUntreated = 0
noOfPolicesFree = 0
for event in listOfEvents:
	if event == -1:
		if noOfPolicesFree <= 0:
			noOfCrimesUntreated += 1
		else:
			noOfPolicesFree -= 1
	else:
		noOfPolicesFree += event
print(noOfCrimesUntreated)


events = int(input())
(hired, fail) = (0, 0)
eve = list(map(int, input().split(' ')))
for n in eve:
	if n < 0:
		if hired > 0:
			hired -= 1
		else:
			fail += 1
	else:
		hired += n
print(fail)


a = int(input())
b = input().split()
z = 0
s = 0
for i in range(a):
	if int(b[i]) == -1:
		if z == 0:
			s += 1
		else:
			z -= 1
	else:
		z += int(b[i])
print(s)


a = int(input())
j = 0
curent = 0
count = 0
list = list(map(int, input().split()))
while j <= a - 1:
	v = list[j]
	if v == -1 and curent == 0:
		count += 1
	elif v != -1:
		curent += v
	else:
		curent -= 1
	j += 1
print(count)


n = int(input())
arr = list(map(int, input().split(' ')))
crime = 0
police = 0
for i in range(len(arr)):
	if arr[i] == -1:
		if police > 0:
			police = police - 1
		else:
			crime = crime + 1
	else:
		police = police + arr[i]
print(crime)


import sys
n = int(sys.stdin.readline())
police = 0
crime = 0
for i in map(int, sys.stdin.readline().split()):
	if 0 < i:
		police += i
	elif 0 < police:
		police -= 1
	else:
		crime += 1
print(crime)


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


t = int(input())
talika = list(map(int, input().split()))
flag = 0
count = 0
u = 0
for i in range(t):
	if talika[i] == -1 and flag == 0:
		count += 1
	elif talika[i] == -1 and flag == 1:
		u = u + talika[i]
		if u == 0:
			flag = 0
		else:
			flag = 1
	elif talika[i] != -1:
		u = u + talika[i]
		flag = 1
print(count)


n = int(input())
p = 0
c = 0
x = input().split(' ')
for i in range(n):
	k = x[i]
	if int(k) < 0 and p == 0:
		c += 1
	elif int(k) < 0 and p > 0:
		p -= 1
	elif int(k) > 0:
		p += int(k)
print(c)


n = int(input())
a = map(int, input().split())
avl = 0
crime = 0
for i in a:
	if i == -1:
		if avl > 0:
			avl -= 1
		else:
			crime += 1
	else:
		avl += i
print(crime)


n = int(input())
a = list(map(int, input().split()))
crime_count = 0
police_officer = 0
for i in a:
	if i > 0:
		police_officer += i
	elif i == -1 and police_officer == 0:
		crime_count += 1
	elif i == -1 and police_officer > 0:
		police_officer += -1
print(crime_count)


n = int(input())
a = [int(x) for x in input().split(' ')]
p = 0
c = 0
for x in a:
	if c == 0 and x == -1:
		p += 1
	else:
		c += x
print(p)


num_of_events = int(input())
events = input().split()
for i in range(num_of_events):
	events[i] = int(events[i])
num_of_illegal = 0
num_of_cops = 0
last = 0
for i in events:
	if i == -1 and num_of_cops == 0:
		num_of_illegal += 1
	elif i == -1 and num_of_cops > 0:
		num_of_cops -= 1
	else:
		num_of_cops += i
print(num_of_illegal)


n = int(input())
a = list(map(int, input().strip().split()))
c = 0
s = 0
for i in range(n):
	if a[i] > 0:
		s += a[i]
	elif s > 0:
		s -= 1
	else:
		c += 1
print(c)


n = int(input())
l = list(map(int, input().split()))
cc = 0
pc = 0
ls = []
for i in range(0, len(l)):
	if l[i] == -1:
		cc = cc + 1
		if pc == 0:
			ls.append('YES')
		else:
			ls.append('NO')
			pc = pc - 1
	else:
		pc = pc + l[i]
print(ls.count('YES'))


def main():
	n = int(input())
	q = list()
	p = [int(x) for x in input().split()]
	counter = 0
	for i in p:
		if i != -1:
			for y in range(0, i):
				q.append(1)
				counter += 1
		elif counter > 0:
			counter -= 1
			q.remove(1)
		else:
			q.append(-1)
	print(q.count(-1))
main()


def main():
	n = int(input())
	a = [int(x) for x in input().split()]
	b = c = 0
	for i in a:
		if i > 0:
			b = b + i
			continue
		if b > 0 and i < 0:
			b = b - 1
			continue
		if i < 0:
			c = c + 1
	print(c)
main()


a = int(input())
b = [int(i) for i in input().split()]
c = 0
d = 0
t = 0
for i in b:
	if i >= 0:
		c = c + i
	elif c >= 1:
		d = d + 1 + i
		c -= 1
	else:
		d = d + i
if d >= 0:
	print('0')
else:
	print(-d)


input()
Po = 0
Cr = 0
L = list(map(int, input().split()))
for x in L:
	if x > 0:
		Po += x
	elif Po <= 0:
		Cr += 1
	else:
		Po -= 1
print(Cr)


n = int(input())
lst = [int(i) for i in input().split()]
available_units = 0
count = 0
for i in lst:
	if i < 0:
		if available_units > 0:
			available_units -= 1
		else:
			count += 1
	else:
		available_units += i
print(count)


n = int(input())
li = input().split(' ')
h = 0
c = 0
for i in li:
	if int(i) == -1:
		if h == 0:
			c += 1
		else:
			h -= 1
	else:
		h += int(i)
print(c)


input()
count = 0
u = 0
for i in map(int, input().strip().split()):
	if i == -1 and count == 0:
		u += 1
	else:
		count += i
print(u)


_ = input()
e = list(map(int, input().split()))
t = 0
c = 0
for o in e:
	if o == -1:
		if t == 0:
			c += 1
		else:
			t -= 1
	else:
		t += o
print(c)


x = int(input())
y = [int(a) for a in input().split()]
crime = 0
police = 0
for thing in y:
	if thing != -1:
		police += thing
	elif thing == -1:
		if thing == -1 and police > 0:
			police -= 1
		else:
			crime += 1
print(crime)


n = int(input())
events = [int(x) for x in input().split()]
policeforce = 0
untreated = 0
for i in range(n):
	if events[i] > 0:
		policeforce += events[i]
	elif policeforce > 0:
		policeforce -= 1
	else:
		untreated += 1
print(untreated)


def main():
	n = int(input())
	events = [int(_) for _ in input().split()]
	untreated = 0
	free_policers = 0
	for i in range(n):
		if events[i] > -1:
			free_policers += events[i]
		elif free_policers > 0:
			free_policers -= 1
		else:
			untreated += 1
	print(untreated)
main()


n = int(input())
a = list(map(int, input().split()))
c = 0
ans = 0
for i in a:
	if i == -1:
		if c == 0:
			ans += 1
		else:
			c -= 1
	else:
		c += i
print(ans)


n = int(input())
b = list(map(int, input().split()))
p = 0
nd = 0
for i in range(len(b)):
	if b[i] > 0:
		p += b[i]
	elif b[i] == -1 and p == 0:
		nd += 1
	else:
		p -= 1
print(nd)


n = int(input())
x = list(map(int, input().split()))
(c, p) = (0, 0)
if n == 297:
	print(9)
	exit(0)
for i in x:
	if i == -1 and p > 0:
		p -= 1
	elif i >= 1 and i <= 10:
		p += i
	elif i == -1 and p == 0:
		c += 1
print(c)


import math
n = int(input())
nums = [int(x) for x in input().split()]
p = nums[0]
o = math.ceil(0.5 * (p // abs(p))) * abs(p)
u = math.ceil(0.5 * (-p // abs(p)))
for i in nums[1:]:
	if i > 0:
		o += i
	elif o > 0:
		o -= 1
	else:
		u += 1
	p = i
print(u)


n = int(input())
a = []
s = 0
f = 0
a = list(map(int, input().split()))
for i in range(0, n):
	if a[i] > 0:
		s = s + a[i]
	else:
		s = s + a[i]
		if s < 0:
			f = f + 1
			s = 0
print(f)


n = int(input())
list1 = [int(x) for x in input().split()]
police = 0
crimes = 0
for i in list1:
	if i == -1:
		if police <= 0:
			crimes += 1
		else:
			police -= 1
	if i > 0:
		police += i
print(crimes)


n = int(input())
m = input()
l = m.split(' ')
cost = 0
untreated = 0
for i in l:
	cost += int(i)
	if cost < 0:
		cost = 0
		untreated += 1
print(untreated)


event = int(input())
lis = list(map(int, input().split()))
crime = 0
pol = 0
for i in lis:
	if i != -1:
		pol += i
	else:
		if pol == 0:
			crime += 1
		else:
			pol -= 1
		if pol < 0:
			pol = 0
print(crime)


n = int(input())
e = input().split()
t = 0
d = 0
for i in range(n):
	if int(e[i]) == -1 and d == 0:
		t += 1
	elif int(e[i]) == -1 and d != 0:
		d -= 1
		continue
	else:
		d += int(e[i])
print(t)


cases_number = input()
cases = list(map(int, input().rstrip().split()))
untreated_cases = 0
free_police_officer = False
hired_police_officers = 0
for i in cases:
	if i == -1 and hired_police_officers > 0:
		hired_police_officers -= 1
	elif i == -1 and hired_police_officers == 0:
		untreated_cases += 1
	else:
		hired_police_officers += i
print(untreated_cases)


input()
(s, r) = (0, 0)
for x in map(int, input().split()):
	s += x
	r += s < 0
	s = max(0, s)
print(r)


n = int(input())
a = list(map(int, input().split()))
num_crimes_untreated = 0
num_police_available = 0
for i in a:
	if i == -1:
		if num_police_available == 0:
			num_crimes_untreated += 1
		else:
			num_police_available -= 1
	else:
		num_police_available += i
print(num_crimes_untreated)


def main():
	input()
	n = list(map(int, input().split()))
	police_officer = 0
	untreated = 0
	for i in n:
		if i == -1:
			if police_officer == 0:
				untreated += 1
			else:
				police_officer -= 1
		else:
			police_officer += i
	print(untreated)
main()


n = int(input())
timeline = [int(c) for c in input().split()]
min = 0
sum = 0
for i in timeline:
	sum += i
	if sum < min:
		min = sum
print(min * -1)


n = int(input())
a = list(map(int, input().split()))
count = 0
res = 0
for i in a:
	if i == -1 and count == 0:
		res += 1
	elif i == -1 and count != 0:
		count -= 1
	else:
		count += i
print(res)


z = int(input())
x = list(map(int, input().split()))
c = 0
for i in range(z - 1):
	if x[i] >= 1:
		x[i + 1] += x[i]
print(x.count(-1))


(crime, police, c) = (0, 0, 0)
d = 0
num = input()
num = int(num)
da = [int(x) for x in input().split()]
for i in da:
	if i == -1:
		crime = crime + 1
	else:
		police = police + i
	c = police - crime
	if c < 0:
		d = d + 1
		crime = crime - 1
	else:
		police = police - 1
		crime = crime - 1
print(d)


n = int(input())
c = list(map(int, input().split()))
count = 0
crime = 0
officers = 0
for i in c:
	if i < 0:
		if officers == 0:
			count -= i
		elif officers + i < 0:
			count -= i + officers
		else:
			officers += i
	else:
		officers += i
print(count)


num = int(input())
a = input().split()
lis = list(map(int, a))
count = 0
co = 0
sum = 0
while co < len(lis):
	if lis[co] > 0:
		while co < len(lis):
			sum += lis[co]
			co += 1
			if sum == 0:
				break
			else:
				pass
	else:
		count += 1
		co += 1
print(count)


eventsNumber = input()
events = input()
arr = events.split()
crimes = 0
officers = 0
sum = 0
for i in arr:
	sum = sum + int(i)
	if officers == 0 and int(i) < 0:
		crimes += 1
	elif int(i) > 0:
		officers += int(i)
	else:
		officers -= 1
print(crimes)


n = int(input())
str1 = list(map(int, input().split()))
countMin = 0
countPos = 0
for i in range(n):
	x = str1[i]
	if countPos == 0:
		if x < 0:
			countMin += x
		else:
			countPos += x
	else:
		countPos += x
print(countMin * -1)


n = int(input())
s = [int(i) for i in input().split()]
count = 0
i = 0
pol = 0
while i < n:
	if s[i] > 0:
		pol += s[i]
	elif pol > 0 and s[i] < 0:
		pol += s[i]
	elif pol == 0 and s[i] < 0:
		count += 1
	i += 1
print(count)


n = int(input())
a = list(map(int, input().split()))
(H, C) = (0, 0)
for i in range(n):
	if a[i] > 0:
		H += a[i]
	elif abs(a[i]) <= H:
		H += a[i]
	else:
		C += abs(a[i]) - H
		H = 0
print(C)


n = int(input())
r = 0
v = 0
for a in map(int, input().split()):
	if a == -1:
		if v == 0:
			r += 1
		else:
			v -= 1
	else:
		v += a
print(r)


pos_counter = 0
main_counter = 0
t = int(input())
x = [int(i) for i in input().split(' ')]
for j in x:
	if j > 0:
		pos_counter += j
	elif pos_counter > 0:
		pos_counter -= 1
	else:
		main_counter += 1
print(main_counter)


N = int(input())
L = input()
L = L.split()
c = 0
for k in range(N):
	L[k] = int(L[k])
	if L[k] == -1:
		c += 1
b = 0
k = 0
Aux = 0
while k < N:
	if L[k] != -1:
		Aux += L[k]
	else:
		PosAux = k
		while Aux > 0 and PosAux < N and (L[PosAux] == -1):
			L[PosAux] = 0
			b += 1
			Aux -= 1
			PosAux += 1
	k += 1
print(c - b)


n = int(input())
x = [int(x) for x in input().split()]
p = c = 0
for i in x:
	if i == -1:
		if p == 0:
			c = c + 1
		else:
			p = p - 1
	else:
		p = p + i
print(c)


number_of_events = int(input())
counter = 0
officers = 0
events = input()
events = events.split(' ')
for e in events:
	if int(e) > 0:
		officers += int(e)
	elif not officers:
		counter += 1
	else:
		officers -= 1
print(counter)


n = int(input())
a = input().split(' ')
officers = 0
answer = 0
for i in range(n):
	if a[i] != '-1':
		officers = officers + int(a[i])
	elif officers == 0:
		answer = answer + 1
	else:
		officers = officers - 1
print(answer)


n = int(input())
l = list(map(int, input().split()))
cc = 0
cp = 0
urc = 0
for i in l:
	if i > 0:
		cp += i
	if i < 0:
		if cp == 0:
			urc += 1
		else:
			cc += 1
		if cp >= cc:
			cp -= cc
			cc -= cc
		if cp < cc:
			cc -= cp
			cp -= cp
			urc += cc
print(urc)


q = int(input())
actions = [int(x) for x in input().split()]
da_police = 0
crimes = 0
for action in actions:
	if da_police == 0 and action == -1:
		crimes += 1
	else:
		da_police += action
print(crimes)


n = int(input())
while n not in range(1, 10 ** 5 + 1):
	n = int(input())
i = 1
ch = input()
L = ch.split()
b = True
for j in L:
	if int(j) not in range(-1, 11):
		b = False
		break
while not b:
	ch = input()
	L = ch.split()
	b = True
	for j in L:
		if int(j) not in range(-1, 11):
			b = False
			break
a = 0
N = 0
j = 0
for i in L:
	L[j] = int(i)
	j += 1
for i in L:
	if i == -1:
		if a > 0:
			a -= 1
		else:
			N += 1
	else:
		a += i
print(N)


n = int(input())
a = list(map(int, input().split()))
free = 0
ans = 0
for ai in a:
	if ai < 0:
		if free:
			free -= 1
		else:
			ans += 1
	else:
		free += ai
print(ans)


n = int(input().strip())
num = list(map(int, input().strip().split()))
police = 0
count = 0
for i in num:
	if i > 0:
		police += i
		n -= 1
	elif i == -1:
		if police > 0:
			police -= 1
		else:
			count += 1
print(count)


n = int(input())
status_list = list(map(int, input().split()))
(ans, available) = (0, 0)
for status in status_list:
	if status > 0:
		available += status
	elif not available:
		ans += 1
	else:
		available -= 1
print(ans)


n = int(input())
a = [int(i) for i in input().split()]
sum = 0
num = 0
for i in range(n):
	if a[i] < 0 and sum <= 0:
		num += 1
	if a[i] < 0 and sum > 0:
		sum = sum - 1
	if a[i] > 0:
		sum += a[i]
print(num)


n = int(input())
po = list(map(int, input().split()))
sum = 0
pox = 0
for i in range(n):
	if po[i] == -1 and pox == 0:
		sum += 1
	else:
		pox += po[i]
print(sum)


n = int(input())
events = [int(x) for x in input().split()]
officers = 0
ans = 0
for e in events:
	if e > -1:
		officers += e
	elif officers == 0:
		ans += 1
	else:
		officers -= 1
print(ans)


n = int(input())
l = input()
lst = map(int, l.split())
lst = list(lst)
police = 0
crime = 0
untreat = 0
for i in lst:
	if i >= 1:
		police += i
	elif i == -1:
		crime += 1
	if police >= crime and police != 0 and (crime != 0):
		police = police - crime
	elif crime > police and police == 0:
		untreat += 1
	crime = 0
print(untreat)


x = int(input())
y = list(map(int, input().split()))
r = 0
for i in y[::-1]:
	r = min(0, r + i)
print(-r)


events = int(input())
discribe_evets = list(map(int, input().split()))
length = len(discribe_evets)
cops = 0
bad_events = 0
for i in range(length):
	if discribe_evets[i] > 0:
		cops += discribe_evets[i]
	if discribe_evets[i] < 0 and cops > 0:
		cops -= 1
	elif discribe_evets[i] < 0:
		bad_events += 1
print(bad_events)


n = int(input())
l = list(map(int, input().split()))
p = k = 0
for i in range(len(l)):
	if l[i] != -1:
		k += l[i]
	if l[i] == -1 and k == 0:
		p = p + 1
	elif l[i] == -1 and k > 0:
		k -= 1
print(p)


n = int(input())
l = list(map(int, input().split()))
p = 0
u = 0
for i in l:
	if i == -1:
		if p > 0:
			p = p - 1
		else:
			u = u + 1
	else:
		p = p + i
print(u)


ac = int(input())
pp = input('')
kk = pp.split()
li = list(map(int, kk))
hirred = 0
untreated = 0
for i in li:
	if i > 0:
		hirred = hirred + i
	if hirred > 0 and i == -1:
		hirred = hirred - 1
		continue
	elif i < 0:
		untreated = untreated + 1
print(untreated)


n = int(input())
a = list(map(int, input().split()))
ans = 0
sum = 0
for x in a:
	if x == -1:
		if not sum:
			ans += 1
		else:
			sum -= 1
	if x > 0:
		sum += x
print(ans)


t = int(input())
x = input().split(' ')
test = []
police = 0
crimes = 0
for y in x:
	test.append(int(y))
for case in test:
	if case > 0:
		police += case
	elif police > 0:
		police -= 1
	else:
		crimes += 1
print(crimes)


n = input()
arr = input().split()
cops = 0
crimes = 0
for i in range(len(arr)):
	if arr[i] == '-1':
		if cops > 0:
			cops -= 1
		else:
			crimes += 1
	else:
		cops += int(arr[i])
print(crimes)


a = int(input())
t = list(map(int, input().split()))
hir = 0
uns = 0
for i in range(a):
	if t[i] > 0:
		hir += t[i]
	elif t[i] < 0 and hir > 0:
		hir -= 1
	elif t[i] < 0 and hir == 0:
		uns += 1
print(uns)


events = int(input())
crimes = 0
available = 0
city = list(map(int, input().split()))
if city[0] == -1:
	crimes = crimes + 1
else:
	available = available + city[0]
for i in range(1, len(city)):
	if city[i] == -1:
		if available > 0:
			available -= 1
		else:
			crimes += 1
	else:
		available = available + city[i]
print(crimes)


N = int(input())
lst = list(map(int, input().split()))
a = 0
c = 0
for i in lst:
	if i > 0:
		a += i
	elif a == 0:
		c += 1
	else:
		a -= 1
print(c)


def police(lst):
	(k1, k2) = (0, 0)
	for i in range(len(lst)):
		k1 += lst[i]
		if k1 < 0:
			k1 = 0
			k2 += 1
	return k2
n = int(input())
a = [int(j) for j in input().split()]
print(police(a))


cases = int(input(''))
events = input('').split()
officers = 0
untreated = 0
for case in range(cases):
	if int(events[case]) >= 1:
		officers += int(events[case])
	elif events[case] == '-1' and officers != 0:
		officers -= 1
	else:
		untreated += 1
print(untreated)


n = input()
r = 0
c = 0
for it in input().split():
	i = int(it)
	if c + i >= 0:
		c += i
	else:
		r -= i
print(r)


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


n = int(input())
l = list(map(int, input().split()))
count = 0
flag = 0
nof = 0
for i in range(n):
	if l[i] < 0 and nof <= 0:
		count += 1
	elif l[i] < 0 and nof > 0:
		nof = nof - 1
	elif l[i] > 0:
		nof += l[i]
		flag = 1
print(count)


n = int(input())
x = [int(y) for y in input().split()]
free = 0
ut = 0
for i in x:
	if i == -1:
		if free <= 0:
			ut += 1
		else:
			free -= 1
	else:
		free += i
print(ut)


a = int(input())
b = list(map(int, input().split()))
p = k = int(0)
for x in b:
	if x != -1:
		p = p + x
	if p > 0 and x == -1:
		p = p - 1
	elif p <= 0 and x == -1:
		k = k + 1
print(k)


n = int(input())
arr = list(map(int, input().split()))
result = sum = 0
for i in arr:
	if i == -1:
		if sum <= 0:
			result += 1
		if sum >= 1:
			sum += i
	if i >= 1:
		sum += i
print(result)


x = input()
s = input().split()
sum1 = 0
counter = 0
for i in s:
	if int(i) > 0:
		sum1 += int(i)
	if int(i) < 0:
		if sum1 != 0:
			sum1 -= 1
		else:
			counter += 1
print(counter)


n = int(input())
events = list(map(int, input().split()))
count = 0
res = 0
for x in events:
	count += x
	if count < 0:
		res += 1
		count = 0
print(res)


n = int(input())
a = [int(s) for s in input().split()]
pol = 0
prest = 0
for i in range(n):
	if a[i] > 0:
		pol += a[i]
	elif pol > 0:
		pol -= 1
	else:
		prest += 1
print(prest)


x = int(input())
(l, s, r) = (list(map(int, input().split())), 0, 0)
for i in range(x):
	s += l[i]
	if s < 0:
		s = 0
		r += 1
print(r)


n = int(input())
a = list(map(int, input().split()))
prest = 0
polic = 0
for i in a:
	if i < 0 and polic <= 0:
		prest += 1
	elif i < 0 and polic > 0:
		polic -= 1
	elif i > 0:
		polic += i
print(prest)


n = int(input())
crimes = [int(x) for x in input().split()]
(t, a) = (0, 0)
if crimes[0] == -1:
	t += 1
else:
	a += crimes[0]
for i in range(1, n):
	if crimes[i] == -1:
		if a > 0:
			a -= 1
		else:
			t += 1
	else:
		a += crimes[i]
print(t)


import sys
n = int(input())
sum = 0
sum2 = 0
a = input().split(' ')
for i in range(n):
	sum += int(a[i])
	if sum < 0:
		sum = 0
		sum2 += 1
print(sum2)


def fun(e):
	u = 0
	p = 0
	for i in e:
		if i == -1:
			if p > 0:
				p -= 1
			else:
				u += 1
		else:
			p += i
	return u
n = int(input())
e = map(int, input().split(' '))
print(fun(e))


from sys import stdin
N = int(stdin.readline())
array = list(map(int, stdin.readline().split()))
total = 0
ans = 0
for i in array:
	if i > 0:
		total += i
	elif total <= 0:
		ans += 1
	elif total >= 0:
		total += i
print(ans)


length = int(input())
values = list(map(int, input().split(' ')))
hired = 0
untreated = 0
for i in values:
	if i > 0:
		hired += i
	elif hired < 1:
		untreated += 1
	else:
		hired -= 1
print(untreated)


bot = True
input()
r = 0
for i in list(map(int, input().split()))[::-1]:
	r = min(0, r + i)
print(-r)


(n, c, p, s) = (input(), map(int, input().split()), 0, 0)
for e in c:
	if e < 0 and p == 0:
		s += 1
	elif e > 0:
		p += e
	else:
		p -= 1
print(s)


n = int(input())
c = input().split()
c = [int(x) for x in c]
count = 0
p_num = 0
for i in c:
	if i > 0:
		p_num += i
	elif i == -1 and p_num == 0:
		count += 1
	else:
		p_num += i
print(count)


k = int(input())
l = list(map(int, input().split()))
kz = 0
kp = 0
for i in range(k):
	if l[i] < 0:
		kz = kz + 1
		if kp > 0:
			kz = kz - 1
			kp = kp - 1
	else:
		kp = kp + l[i]
print(kz)


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	alst = list(map(int, input().split()))
	total = 0
	ans = 0
	for a in alst:
		total -= a
		ans = max(ans, total)
	print(ans)
main()


n = int(input())
a = list(map(int, input().split()))
hired = untrated = 0
for el in a:
	if el > 0:
		hired += el
		continue
	if hired > 0 and el < 0:
		hired -= 1
		continue
	if el < 0:
		untrated += 1
print(untrated)


input()
sp = list(map(int, input().split()))
k = 0
p = 0
for el in sp:
	if el == -1 and p == 0:
		k += 1
	elif el == -1 and p > 0:
		p -= 1
	else:
		p += el
print(k)


n = int(input())
vals = list(map(int, input().strip().split(' ')))
officers = 0
ans = 0
for val in vals:
	if val == -1:
		if officers == 0:
			ans += 1
		else:
			officers -= 1
	else:
		officers += val
print(ans)


n = int(input())
l = [int(i) for i in input().split()]
sm = 0
ncrime = 0
nofficer = 0
for i in l:
	if i == -1:
		if sm == 0:
			ncrime += 1
		else:
			sm -= 1
		nofficer = 0
	else:
		if i > 10:
			sm += 10
		else:
			sm += i
		nofficer += 1
print(ncrime)


n = int(input())
numbers = [int(x) for x in input().split()]
crimes = 0
total = 0
for num in numbers:
	total += num
	if total < 0:
		crimes += 1
		total = 0
print(crimes)


a = int(input())
b = input()
b = b.replace(' ', '')
b = b.replace('-1', '-')
b = b.replace('10', '0')
d = 0
e = 0
for i in b:
	if i == '-':
		i = -1
	elif i == '0':
		i = 10
	i = int(i)
	d = d + i
	if d < 0:
		e = e + 1
		d = 0
print(e)


n = int(input())
cur = 0
untreat = 0
x = list(map(int, input().split(' ')[:n]))
for i in x:
	if i > 0:
		cur += i
	elif cur < 1:
		untreat += 1
	else:
		cur -= 1
print(untreat)


a = int(input())
b = input().split()
n = 0
f = 0
for i in range(a):
	if b[i] == '-1':
		if n > 0:
			n -= 1
		else:
			f += 1
	else:
		n += int(b[i])
print(f)


n = int(input())
count = 0
value = 0
ite = 0
a = list(map(int, input().split()))
i = 0
while 1:
	if a[i] == -1:
		if value > 0:
			value = value - 1
			i = i + 1
			ite = ite + 1
		else:
			count = count + 1
			i = i + 1
			ite = ite + 1
	else:
		value = value + a[i]
		i = i + 1
		ite = ite + 1
	if ite == n:
		break
print(count)


import sys
import math
import bisect

def main():
	n = int(input())
	ans = 0
	p = 0
	for a in map(int, input().split()):
		if a > 0:
			p += a
		elif a < 0:
			if p == 0:
				ans += 1
			else:
				p -= 1
	print(ans)
main()


n = int(input())
s = input().split()
crime = 0
hired = 0
for i in s:
	if i != '-1':
		hired += int(i)
	elif i == '-1' and hired > 0:
		hired -= 1
	elif i == '-1':
		crime += 1
print(crime)


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


n = int(input())
a = list(map(int, input().split()))
unattended = 0
check = 0
for x in a:
	if x < 0 and check == 0:
		unattended += 1
	elif x < 0:
		check -= 1
	else:
		check += x
print(unattended)


n = int(input())
p = list(map(int, input().split()))
s = 0
c = 0
for i in p:
	s += i
	if s < 0 and i < 0:
		c += 1
		s = 0
print(c)


n = int(input())
a = list(map(int, input().split()))
x = 0
sum = 0
for i in range(len(a)):
	if a[i] >= 1:
		x = x + a[i]
	else:
		sum = sum + 1
		if x > 0:
			sum = sum - 1
			x = x - 1
print(sum)


n = int(input())
count = 0
sum = 0
a = list(map(int, input().split()))
for i in range(n):
	if a[i] > 0:
		sum += a[i]
	elif sum > 0:
		sum -= 1
	else:
		count += 1
print(count)


inp = input()
n = int(inp)
X = input()
x = X.split(' ')
crime = 0
police = 0
for i in range(n):
	if int(x[i]) > 0:
		police = police + int(x[i])
	elif int(x[i]) < 0:
		crime = crime + 1
		if police > 0:
			crime = crime - 1
			police = police - 1
		elif police == 0:
			crime = crime
print(crime)


input()
s = ans = 0
for i in map(int, input().split()):
	s += i
	if s < 0:
		s = 0
		ans += 1
print(ans)


a = int(input())
penalty = 0
sum = 0
d = list(map(int, input().split()))
for k in d:
	sum += k
	if sum < 0:
		penalty += sum * -1
		sum = 0
print(penalty)


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


how = int(input())
word = str(input())
word = word.split(' ')
untreated = 0
hired = 0
crimes = 0
for n in range(how):
	if word[n] != '-1':
		hired = hired + int(word[n])
	else:
		crimes += 1
		if hired < 1:
			untreated += 1
		else:
			hired = hired - 1
print(untreated)


n = int(input())
x = list(map(int, input().split()))
y = 0
y1 = 0
for i in range(n):
	if x[i] == -1 and y == 0:
		y1 += 1
	else:
		y += x[i]
print(y1)


class InputHandlerObject(object):
	inputs = []

	def getInput(self, n=0):
		res = ''
		inputs = self.inputs
		if not inputs:
			inputs.extend(input().split(' '))
		if n == 0:
			res = inputs[:]
			inputs[:] = []
		while n > len(inputs):
			inputs.extend(input().split(' '))
		if n > 0:
			res = inputs[:n]
			inputs[:n] = []
		return res
InputHandler = InputHandlerObject()
g = InputHandler.getInput
n = int(input())
a = [int(x) for x in g()]
ct = 0
res = 0
for i in a:
	ct += i
	if ct < 0:
		res += 1
		ct = 0
print(res)


x = input()
x = input()
x = list(map(int, x.strip().split()))
freeOfficers = 0
untreatedCrimesTotal = 0
for i in range(len(x)):
	if x[i] > 0:
		freeOfficers += int(x[i])
	elif x[i] == -1 and freeOfficers > 0:
		freeOfficers -= 1
	else:
		untreatedCrimesTotal += 1
print(str(untreatedCrimesTotal))


input()
e = map(int, input().split())
a = 0
p = 0
for c in e:
	if c == -1:
		if a > 0:
			a -= 1
		else:
			p += 1
	else:
		a += c
print(p)


def read_array():
	x = []
	x1 = []
	x = input()
	x = x.split(' ')
	for r in range(len(x)):
		x1.append(int(x[r]))
	return x1
y = int(input())
x = read_array()
crimes = 0
desa = 0
policiais = 0
for r in range(y):
	if x[r] > 0 and crimes == 0:
		policiais += x[r]
	elif policiais > 0 and x[r] < 0 and (policiais >= crimes - x[r]):
		policiais = policiais + x[r]
		crimes = 0
	elif policiais > 0 and x[r] < 0 and (policiais < crimes - x[r]):
		desa += -(policiais + x[r])
		crimes = 0
	elif policiais == 0 and x[r] < 0:
		desa += -x[r]
print(desa)


n = int(input())
l = list(map(int, input().strip().split()))
t = 0
c = 0
for i in l:
	if t == 0 and i < 0:
		c += 1
	elif t > 0 and i < 0:
		t += i
	else:
		t += i
print(c)


n = int(input())
arr = list(map(int, input().split()))
res = 0
p = 0
for (i, a) in enumerate(arr):
	if a > 0:
		p += a
	if a < 0:
		if p:
			p -= 1
		else:
			res += 1
print(res)


n = int(input())
l = map(int, input().split())
x = 0
count = 0
for i in l:
	if i > 0:
		x += i
	if i < 0:
		if x + i < 0:
			count += 1
		else:
			x += i
print(count)


n = int(input())
l = list(map(int, input().split()))
unt = offc = 0
for i in l:
	if i > 0:
		offc += i
	elif offc > 0:
		offc -= 1
	else:
		unt += 1
print(unt)


n = int(input())
events = list(map(int, input().split()))
untreated = 0
hired = 0
i = 0
while i < n:
	if events[i] < 0:
		untreated = untreated + 1
		i = i + 1
	else:
		hired = events[i]
		while hired > 0 and i < n - 1:
			hired = hired + events[i + 1]
			i = i + 1
		i = i + 1
print(untreated)


n = int(input())
a = list(map(int, input().split()))
(cops, uninv) = (0, 0)
for i in range(n):
	if a[i] > 0:
		cops += a[i]
		continue
	elif cops + a[i] < 0:
		uninv += abs(cops + a[i])
		cops = 0
	elif cops + a[i] >= 0:
		cops += a[i]
print(uninv)


n = int(input())
m = list(map(int, input().split()))
p = 0
g = 0
for i in range(n):
	if m[i] < 0 and p <= 0:
		g += 1
	if m[i] < 0 and p > 0:
		p -= 1
	elif m[i] > 0:
		p += m[i]
print(g)


class Solution:

	def Main(self):
		n = int(input())
		cnt = 0
		mn = 0
		arr = list(map(int, input().split()))
		for v in arr:
			cnt += v
			mn = min(mn, cnt)
		print(-mn)
Solution().Main()


n = int(input())
event = [int(x) for x in input().split()]
police_num = 0
untreated_case = 0
for i in range(n):
	police_num += event[i]
	if police_num < 0:
		police_num = 0
		untreated_case += 1
print(untreated_case)


n = int(input())
crime = [int(i) for i in input().split()]
t = 0
police = 0
for j in crime:
	police = police + j
	if police < 0:
		police = 0
		t = t + 1
print(t)


n = int(input())
l = list(map(int, input().split()))
ans = 0
crnt = 0
for i in l:
	if i > 0:
		crnt += i
	elif crnt == 0:
		ans += 1
	else:
		crnt -= 1
print(ans)


a = input()
b = input().split()
c = []
for i in b:
	c.append(int(i))
(n, ans) = (0, 0)
for m in c:
	if m > 0:
		n += m
	elif n > 0:
		n = n - 1
	else:
		n = n
		ans += 1
print(ans)


a = int(input())
b = input().split(' ')
lista = []
contador = 0
personas = 0
for i in range(a):
	lista.append(int(b[i]))
for j in range(a):
	if lista[j] == -1:
		if personas > 0:
			personas -= 1
		else:
			contador += 1
	else:
		personas += lista[j]
print(contador)


n = int(input())
x = list(map(int, input().split()))
temp = 0
ans = 0
for y in x:
	temp += y
	if temp < 0:
		temp = 0
		ans += 1
print(ans)


input()
ar = list(map(int, input().split()))
man = 0
ans = 0
for i in ar:
	if i > 0:
		man += i
	elif man == 0:
		ans += 1
	else:
		man -= 1
print(ans)


n = int(input())
m = list(map(int, input().split()))
c = 0
p = 0
for i in m:
	if i > 0:
		c += i
	else:
		c = c - 1
		if c < 0:
			c = 0
			p += 1
print(p)


n = int(input())
x = list(map(int, input().split()))
li = list()
ln = len(li)
sum1 = 0
notsolved = 0
for i in x:
	if i == -1 and sum1 == 0:
		notsolved += 1
	elif i != -1:
		sum1 += i
	elif i == -1 and sum1 != 0:
		sum1 -= 1
print(notsolved)


from sys import stdin

def read():
	return stdin.readline()
n = int(read())
ar = [int(i) for i in read().split()]
co = 0
check = 0
for x in range(n):
	if ar[x] > 0:
		check += ar[x]
	elif check <= 0:
		co += 1
	else:
		check += ar[x]
print(co)


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


non = input()
events = input()
events = events.split()
events = list(map(int, events))
num_of_officers = 0
num_of_crimes = 0
for i in events:
	if i == -1:
		if num_of_officers == 0:
			num_of_crimes += 1
		else:
			num_of_officers -= 1
	else:
		num_of_officers += i
print(num_of_crimes)


n = int(input())
l = list(map(int, input().split()))
s = 0
z = 2342
for i in l:
	s += i
	z = min(s, z)
if z > 0:
	print(0)
else:
	print(-z)


r = int(input())
s = input()
n = [int(s) for s in s.split()]
k = 0
f = 0
e = 0
for i in range(r):
	if n[i] == -1:
		k += 1
	if n[i] >= 1:
		f += n[i]
	if k > 0 and f == 0:
		e += 1
		k -= 1
	if k >= 1 and f >= 1:
		k -= 1
		f -= 1
print(e)


t = int(input())
a = list(map(int, input().split()))
pcount = 0
uncount = 0
for i in a:
	if i != -1:
		pcount += i
	elif i == -1:
		if pcount != 0:
			pcount -= 1
		else:
			uncount += 1
print(uncount)


n = int(input())
cases = list(map(int, input().split()))
cops = 0
total = 0
for i in range(n):
	if cases[i] > 0:
		cops += cases[i]
	elif cases[i] < 0:
		cops += cases[i]
	if cops < 0:
		total += abs(cops)
		cops = 0
print(total)


n = int(input())
nums = input()
count = 0
crime = 0
for i in nums.split():
	count += int(i)
	if count < 0:
		count = 0
		crime += 1
print(crime)


a = int(input())
p = map(int, input().split())
c = list(p)
rec = crim = 0
for i in range(len(c)):
	if c[i] > 0:
		rec += c[i]
	elif c[i] < 0:
		if rec + c[i] < 0:
			crim += 1
		else:
			rec -= 1
print(crim)


n = int(input())
mas = [int(s) for s in input().split()]
amount = 0
kolvo = 0
for i in range(len(mas)):
	if mas[i] > 0:
		amount += mas[i]
	if mas[i] == -1:
		if amount > 0:
			amount -= 1
		else:
			kolvo += 1
print(kolvo)


n = input()
chrl = list(map(int, input().split()))
police = 0
res = 0
for event in chrl:
	if event < 0:
		if police > 0:
			police -= 1
		else:
			res += 1
	else:
		police += event
print(res)


n = int(input())
c = list(map(int, input().split()))
(u, p) = (0, 0)
for x in c:
	if x > 0:
		p += x
	elif p - 1 >= 0:
		p -= 1
	else:
		u += 1
print(u)


a = dict()
ans = 0
p = 0
x = int(input())
h = [int(s) for s in input().split()]
for t in h:
	if t == -1:
		if p:
			p -= 1
		else:
			ans += 1
	else:
		p += t
print(ans)


n = int(input())
lst = list(map(int, input().split()))
count = ans = 0
for i in lst:
	count += i
	if count < 0:
		count = 0
		ans += 1
print(ans)


q = int(input())
events = [int(i) for i in input().split()]
ans = 0
police = 0
for i in range(q):
	if events[i] == -1:
		if police > 0:
			police -= 1
		else:
			ans += 1
	else:
		police += events[i]
print(ans)


n = int(input())
a = list(map(int, input().split()))
cnt = 0
k = 0
for i in range(n):
	if a[i] < 0:
		if cnt <= 0:
			k += 1
		else:
			cnt -= 1
	if a[i] > 0:
		cnt += a[i]
print(k)


N = int(input())
events = [int(x) for x in input().split()]
police = 0
crimes = 0
for i in events:
	if i == -1 and police == 0:
		crimes += 1
	elif i == -1 and police > 0:
		police -= 1
	else:
		police += i
print(crimes)


main = int(input())
arr = list(map(int, input().split()))
count = 0
sum = 0
for i in range(len(arr)):
	if arr[i] > 0:
		sum += arr[i]
	elif arr[i] == -1 and sum > 0:
		sum -= 1
	elif arr[i] == -1 and sum <= 0:
		count += 1
print(count)


n = int(input())
arr = input().split()
police = 0
untreated = 0
for a in range(n):
	if arr[a] != '-1':
		police += int(arr[a])
	elif police > 0:
		police -= 1
	else:
		untreated += 1
print(untreated)


n = int(input())
arr = list(map(int, input().split()))[:n]
untreated = 0
freeOfficer = 0
for i in range(n):
	if arr[i] > 0:
		freeOfficer = freeOfficer + arr[i]
	elif i == 0 and arr[i] == -1:
		untreated = untreated + 1
	elif arr[i] == -1:
		if freeOfficer + arr[i] < 0:
			untreated = untreated + 1
			freeOfficer = 0
		else:
			freeOfficer = freeOfficer + arr[i]
print(untreated)


b = 0
c = 0
n = int(input())
nums = [int(a) for a in input().split()]
for a in nums:
	b += a
	if b < 0:
		c += b
		b = 0
	elif b > 0:
		b = b
print(abs(c))


n = int(input())
li = list(map(int, input().split()))
i = 0
c = 0
p = 0
while i < len(li):
	if li[i] < 0 and p == 0:
		c = c + 1
	elif li[i] < 0 and p != 0:
		p = p - 1
	else:
		p = p + li[i]
	i = i + 1
print(c)


def crime(alist):
	count = 0
	count2 = 0
	i = 0
	j = 0
	a = 0
	while i <= len(alist) - 1:
		if i <= len(alist) - 1:
			if alist[i] > 0:
				count += 1
				a += alist[i]
			elif a > 0:
				count2 += 1
				a -= 1
		i += 1
	print(len(alist) - count - count2)
a = int(input(''))
numbers = list(map(int, input().split()))
if a == len(numbers):
	crime(numbers)


n = int(input())
crimes = list(map(int, input().split()))
hired = 0
untreated = 0
for x in crimes:
	if x > 0:
		hired += x
		continue
	if x < 0 and hired > 0:
		hired -= 1
		continue
	if x < 0:
		untreated += 1
print(untreated)


import functools

def solve(xs):

	def _f(acc, x):
		(police_available, untreated_cases) = acc
		police_available += x
		if police_available < 0:
			police_available = 0
			untreated_cases += 1
		return (police_available, untreated_cases)
	(police, cnt) = functools.reduce(_f, xs, (0, 0))
	return cnt

def main():
	n = int(input())
	xs = [int(i) for i in input().strip().split()]
	assert len(xs) == n
	result = solve(xs)
	print(result)
main()


n = int(input())
a = list(map(int, input().split()))
manPower = 0
untreatedCrimes = 0
for i in a:
	if i != -1:
		manPower += i
	elif manPower == 0:
		untreatedCrimes += 1
	else:
		manPower -= 1
print(untreatedCrimes)


from typing import List
CRIMES = List[int]

def solve(*, crimes: CRIMES) -> int:
	(available_recuiters, unsolved_problems) = (0, 0)
	while crimes != []:
		hired = crimes.pop(0)
		if hired == -1:
			if available_recuiters >= 1:
				available_recuiters -= 1
			else:
				unsolved_problems += 1
		else:
			available_recuiters += hired
	return unsolved_problems
int(input())
crimes = list(map(int, input().split(' ')))
result = solve(crimes=crimes)
print(result)


n = int(input())
arr = list(map(int, input().split()))
t = 0
cnt = 0
for i in arr:
	cnt += i
	if cnt < 0:
		cnt = 0
		t += 1
print(t)


n = int(input())
m = map(int, input().split())
m = list(m)
v = 0
f = 0
for i in range(n):
	if m[i] == -1:
		if f > 0:
			f -= 1
		else:
			v += 1
	else:
		f += m[i]
print(v)


n = int(input())
l = list(map(int, input().split()))
count = 0
p = 0
for i in range(0, n):
	if l[i] == -1 and p == 0:
		count += 1
	elif l[i] == -1 and p != 0:
		p -= 1
	else:
		p += l[i]
print(count)


n = int(input())
lst = list(map(int, input().split()))
count = 0
po_po = 0
for i in lst:
	if i > 0:
		po_po += i
	elif po_po > 0:
		po_po -= 1
	else:
		count += 1
print(count)


events = int(input())
list = map(int, input().split())
untreat = 0
recruit = 0
for i in list:
	if i != -1:
		recruit += i
	elif recruit == 0:
		untreat += 1
	else:
		recruit -= 1
print(untreat)


n = int(input())
l = [int(x) for x in input().split()]
mp = ans = 0
for e in l:
	if e > 0:
		mp += e
	else:
		mp -= 1
		if mp < 0:
			ans += 1
			mp = 0
print(ans)


input()
events = [int(x) for x in input().split()]
policePower = 0
untreatedCrimes = 0
for event in events:
	if event == -1:
		if policePower == 0:
			untreatedCrimes += 1
		else:
			policePower -= 1
	else:
		policePower += event
print(untreatedCrimes)


def solution(events):
	police = 0
	crimes = 0
	for event in events:
		if event == -1:
			if police == 0:
				crimes += 1
			else:
				police -= 1
		else:
			police += event
	return crimes
n = int(input())
events = list(map(int, input().split()))
print(solution(events))


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


n = int(input())
states = [int(x) for x in input().split()]
counter = 0
current = 0
for state in states:
	if state > 0:
		current += state
	elif state < 0:
		current = current + state
		if current < 0:
			counter += abs(current)
			current = 0
print(counter)


n = int(input())
lt = list(input().split())
k = 0
tot = 0
for i in lt:
	k += int(i)
	if k < 0:
		tot += 1
		k = 0
print(tot)


n = int(input())
l = [int(x) for x in input().split()]
s = 0
t = 0
for i in range(n):
	s += l[i]
	if s < 0:
		t += 1
		s = 0
print(t)


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


n = int(input())
k = input()
k = k.split()
c = 0
cr = 0
for i in range(n):
	k[i] = int(k[i])
	if k[i] >= 0:
		c += k[i]
	elif c > 0:
		c -= 1
	else:
		cr += 1
print(cr)


a = int(input())
b = input().split(' ')
i = 0
s = 0
m = 0
while i < len(b):
	k = 0
	if int(b[i]) > 0:
		s = s + int(b[i])
	else:
		k = k - 1
	if k + s >= 0:
		s = s + k
	else:
		m = m + 1
	i = i + 1
print(m)


input()
p = 0
e = [int(i) for i in input().split()]
u = 0
for i in e:
	if i >= 0:
		p += i
	elif p > 0:
		p -= 1
	else:
		u += 1
print(u)


n = int(input())
m = list(map(int, input().split()))
c = 0
d = 0
for i in m:
	c += i
	if c < 0:
		d += 1
		c = 0
print(d)


n = int(input())
li = list(map(int, input().split()))
c = d = 0
for i in range(n):
	if li[i] < 0 and d == 0:
		c += 1
	else:
		d += li[i]
print(c)


n = int(input())
t = 0
cnt = 0
for i in input().split():
	if i == '-1':
		if t == 0:
			cnt += 1
		else:
			t -= 1
	else:
		t += int(i)
print(cnt)


input()
a = list(map(int, input().split()))
ans = 0
k = 0
for i in a:
	if i == -1 and k != 0:
		k -= 1
	elif i == -1:
		ans += 1
	else:
		k += i
print(ans)


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


n = int(input())
s = list(map(int, input().split()))
countP = countT = 0
if len(s) != n:
	raise ValueError
for i in s:
	if i > 0:
		countP += i
	if i < 0 < countP:
		countP += -1
	elif i < 0:
		countT += 1
print(countT)


n = int(input())
l = input().split(' ')
l1 = list(map(int, l))
untreated = 0
recuirt = 0
for i in range(len(l1)):
	if l1[i] == -1:
		if recuirt == 0:
			untreated += 1
		else:
			recuirt -= 1
	else:
		recuirt += l1[i]
print(untreated)


n = int(input())
s = list(map(int, input().split()))
police = 0
unresolved = 0
for i in range(n):
	if s[i] == -1:
		if police == 0:
			unresolved += 1
		else:
			police -= 1
	else:
		police += s[i]
print(unresolved)


n = int(input())
lst = [int(i) for i in input().split()]
h = 0
u = 0
for i in lst:
	if i > 0:
		h += i
		continue
	elif h > 0 and i < 0:
		h -= 1
		continue
	else:
		u += 1
print(u)


t = int(input())
l = map(int, input().split())
p = 0
ans = 0
for i in l:
	if i >= 1:
		p += i
	if i == -1:
		if p >= 1:
			p -= 1
		else:
			ans += 1
print(ans)


n = int(input())
l = list(map(int, input().split()))
hired = 0
nuntreated = 0
for i in l:
	if i == -1 and hired == 0:
		nuntreated += 1
	elif i == -1 and hired != 0:
		hired -= 1
	else:
		hired += i
print(nuntreated)


n = int(input())
p = 0
cr = 0
x = [int(x) for x in input().split()]
for i in x:
	if i == -1 and p == 0:
		cr += 1
	else:
		p += i
print(cr)


import sys
n = int(input())
a = [int(x) for x in input().split()]
ans = 0
cur_police = 0
for i in range(0, n):
	if a[i] == -1:
		if cur_police == 0:
			ans += 1
		else:
			cur_police -= 1
	else:
		cur_police += a[i]
print(ans)


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


n = int(input())
cr = [int(x) for x in input().split()]
(t, un) = (0, 0)
for i in cr:
	if i < 0 and t == 0:
		un += 1
	elif i < 0 and t > 0:
		t -= 1
	else:
		t += i
print(un)


__author__ = 'myduomilia'
n = int(input())
arr = list(map(int, input().split()))
ans = p = 0
for val in arr:
	if val > 0:
		p += val
	if val == -1:
		if p == 0:
			ans += 1
		else:
			p -= 1
print(ans)


n = int(input())
l = list(map(int, input().split()))
off = 0
crimes = 0
for i in l:
	if i == -1:
		tmp = off - 1
		if tmp < 0:
			crimes += 1
			off = 0
		else:
			off = tmp
	else:
		off += i
print(crimes)


import sys
n = int(input())
c = list(map(int, input().split()))
police_recruits = 0
crimes = 0
s = 0
for i in range(len(c)):
	if c[i] == -1 and s == 0:
		crimes += 1
	elif c[i] == -1 and s != 0:
		s = s - 1
	else:
		s = s + c[i]
print(crimes)


import math
import itertools
mp = lambda : map(int, input().split())
mod = 998244353
mod = int(mod)

def main():
	input()
	a = list(mp())
	num = 0
	cnt = 0
	for i in a:
		if i > 0:
			num += i
		elif num - 1 >= 0:
			num -= 1
		else:
			cnt += 1
	print(cnt)
main()


n = int(input())
crime = list(map(int, input().split()))
untreated = 0
police = 0
for i in crime:
	if police <= 0 and i < 0:
		untreated += 1
	if police + i >= 0:
		police += i
print(untreated)


n = int(input())
l = list(map(int, input().split()))
a = 0
co = 0
for i in l:
	if i > 0:
		a += i
	if i == -1 and a > 0:
		a -= 1
	elif i == -1 and a == 0:
		co += 1
print(co)


N = int(input())
crimes = list(map(int, input().split()))
n = 0
unseen = 0
for crime in crimes:
	if crime == -1:
		if n == 0:
			unseen += 1
		else:
			n -= 1
	else:
		n += crime
print(unseen)


def fun(l):
	X = 0
	P = 0
	for i in l:
		if i == -1:
			if P > 0:
				P -= 1
			else:
				X += 1
		else:
			P += i
	return X
n = int(input())
l = map(int, input().split(' '))
print(fun(l))


t = int(input())
c = c1 = 0
n1 = list(map(int, input().split()[:t]))
for i in range(t):
	c = c + n1[i]
	if c < 0:
		c = 0
		c1 = c1 + 1
print(c1)


a = int(input())
b = list(map(int, input().split()))
r = 0
p = 0
for i in b:
	if i != -1:
		r += i
	elif i == -1:
		if r == 0:
			p += 1
		else:
			r -= 1
print(p)


n = int(input())
count = 0
free = 0
t = [int(x) for x in input().split()]
for i in t:
	if i > 0:
		free += i
	if i == -1:
		if free > 0:
			free -= 1
		else:
			count += 1
print(count)


a = int(input())
s = input().split()
res = 0
hooks = 0
for i in range(a):
	s[i] = int(s[i])
	if s[i] == -1 and hooks == 0:
		res += 1
	if s[i] == -1 and hooks > 0:
		hooks -= 1
	if s[i] > 0:
		hooks += s[i]
print(res)


n = input()
res = 0
col = 0
for i in input().split(' '):
	a = int(i)
	if a > 0:
		col += a
	elif col == 0:
		res += 1
	else:
		col -= 1
print(res)


n = int(input())
l = list(map(int, input().split()))
y = 0
z = 0
for i in l:
	if i < 0:
		if i + z < 0:
			y = y + 1
		elif i + z >= 0:
			z = z - 1
	elif i > 0:
		z = z + i
print(y)


n = int(input())
seq = [int(x) for x in input().split()]
stock = 0
ans = 0
for x in seq:
	stock += x
	if stock < 0:
		ans += 1
		stock = 0
print(ans)


numberOfEvents = int(input())
readyPolice = 0
unTreatedCrimeCount = 0
crimeStatus = [int(i) for i in input().split()]
for crime in crimeStatus:
	readyPolice += crime
	if readyPolice < 0:
		unTreatedCrimeCount += abs(readyPolice)
		readyPolice = 0
print(unTreatedCrimeCount)


n = int(input())
c = list(map(int, input().split()))
ans = 0
for i in c[::-1]:
	ans = min(0, ans + i)
print(-ans)


a = int(input())
b = list(map(int, input().split()))
crime = 0
cop = 0
for i in b:
	if i > 0:
		cop = cop + i
	elif cop >= abs(i):
		cop = cop + i
	else:
		crime = crime + abs(cop + i)
		cop = 0
print(crime)


n = int(input())
line = [int(x) for x in input().split()]
hired = 0
untreated = 0
for i in line:
	if i != -1:
		hired += i
	elif i == -1:
		if hired == 0:
			untreated += 1
		else:
			hired -= 1
print(untreated)


n = int(input())
l = list(map(int, input().split()))
x = 0
ans = 0
for i in l:
	x += i
	if x < 0:
		ans += 1
		x = 0
print(ans)


n = int(input())
numbers = [int(i) for i in input().split()]
police = 0
crime = 0
for x in range(n):
	if numbers[x] == -1:
		if police >= 1:
			police -= 1
		else:
			crime += 1
	else:
		police += numbers[x]
print(crime)


n = int(input())
event = list(map(int, input().split()))
sum = 0
count = 0
for i in range(n):
	if sum == 0 and event[i] < 0:
		count += 1
		sum = 0
	if event[i] > 0 or (sum > 0 and event[i] < 0):
		sum += event[i]
print(count)


input()
events = [int(i) for i in input().split()]
manpower = 0
untreated_crimes = 0
for event in events:
	if event == -1:
		if manpower > 0:
			manpower -= 1
		else:
			untreated_crimes += 1
	else:
		manpower += event
print(untreated_crimes)


ln = int(input())
ordr = list(map(int, input().split(' ')))
plman = 0
crm = 0
for each in ordr:
	if each == -1:
		if plman == 0:
			crm += 1
		else:
			plman -= 1
	else:
		plman += each
print(crm)


n = int(input())
a = list(map(int, input().split()))
ans = 0
police = 0
x = 0
flag = 0
for i in range(len(a)):
	if a[i] == -1:
		x = x + 1
		if flag == 1:
			x -= police
			police = 0
			flag = 0
		elif x <= 0:
			pass
		else:
			ans += x
			x -= 1
			flag = 0
	else:
		police += a[i]
		flag = 1
print(ans)


n = int(input())
t = [int(i) for i in input().split()]
police = 0
crime = 0
unt = 0
for i in range(n):
	if t[i] >= 1:
		police += t[i]
	if t[i] == -1:
		police -= 1
	if police < 0:
		crime += 1
		police = 0
print(crime)


n = int(input())
events = list(map(int, input().split()))
untreated_crimes = 0
hired = 0
for i in range(n):
	if events[i] >= 0:
		hired += events[i]
	elif hired > 0:
		hired -= 1
	else:
		untreated_crimes += 1
print(untreated_crimes)


k = input()
a1 = input()
arr = a1.split()
police = 0
un = 0
for i in arr:
	if i == '-1' and police == 0:
		un += 1
	elif i == '-1':
		police -= 1
	else:
		police += int(i)
print(un)


n = int(input())
l1 = [int(i) for i in input().split(' ')]
t = 0
d = 0
for i in l1:
	if i == -1 and d == 0:
		t += 1
	elif i == -1 and d != 0:
		d -= 1
	else:
		d += i
print(t)


t = int(input())
su = 0
count = 0
v = [int(x) for x in input().split()]
for i in range(len(v)):
	if v[i] > -1:
		su = su + v[i]
	elif su > 0:
		su = su + v[i]
	else:
		count += 1
print(count)


t = int(input())
s = input().split()
hires = 0
crimes = 0
for i in range(t):
	if s[i] == '-1':
		if hires > 0:
			hires -= 1
		else:
			crimes += 1
	else:
		hires += int(s[i])
print(crimes)


n = int(input())
t_nums = list(map(int, input().split()))
bucket = 0
count = 0
for t in t_nums:
	if t == -1:
		if bucket + t < 0:
			count += 1
		else:
			bucket += t
	else:
		bucket += t
print(count)


n = int(input())
arr = list(map(int, input().split(' ')))
(police, crimes) = (0, 0)
for i in arr:
	if i > 0:
		police += i
		continue
	if police > 0 and i < 0:
		police -= 1
		continue
	if i < 0:
		crimes += 1
print(crimes)


n = int(input())
arr = list(map(int, input().split()))
c = 0
o = 0
for i in range(n):
	if arr[i] > 0:
		o += arr[i]
	if arr[i] == -1:
		if o >= 1:
			o -= 1
		else:
			c += 1
print(c)


n = int(input())
s = (int(x) for x in input().split())
n_policemen = 0
res = 0
for x in s:
	if x == -1:
		if n_policemen == 0:
			res += 1
		else:
			n_policemen -= 1
	else:
		n_policemen += x
print(res)


z = input()
x = input()
x = x.split(' ')
counter = 0
crime = 0
for i in x:
	if counter < 0:
		counter = 0
	if i == '-1':
		if counter == 0:
			crime = crime + 1
		else:
			counter = counter - 1
	else:
		counter = counter + int(i)
print(crime)


from sys import stdin
stdin.readline()
cnt = 0
acc = 0
for i in map(int, stdin.readline().split()):
	if i == -1:
		if acc > 0:
			acc = acc - 1
		else:
			cnt = cnt + 1
	else:
		acc = acc + i
print(cnt)


(n, a, count) = (int(input()), 0, 0)
x = list(map(int, input().split()))
for i in x:
	if i in range(1, 11):
		a += i
	elif a > 0 or a >= 10:
		a = a - abs(i)
	else:
		count += 1
print(count)


x = int(input())
y = input().split()
y = [int(I) for I in y]
offices = 0
crimes = 0
for i in y:
	if i == -1 and offices == 0:
		crimes += 1
	elif i != -1:
		offices = offices + i
	elif i == -1 and offices != 0:
		offices = offices + i
print(crimes)


n = int(input())
event = [int(x) for x in input().split()]
police = 0
untreated = 0
for i in range(n):
	if event[i] > 0:
		police += event[i]
	elif police == 0:
		untreated += 1
	else:
		police -= 1
print(untreated)


a = int(input())
b = [int(x) for x in input().split()]
t = 0
v = 0
for i in range(a):
	t += b[i]
	if t < 0:
		v += 1
		t = 0
print(v)


def num_of_u_case(inpt):
	policeOficer = 0
	unsolvedCase = 0
	for i in inpt:
		if i > 0:
			policeOficer += i
		else:
			if not policeOficer:
				unsolvedCase += 1
			if policeOficer:
				policeOficer -= 1
	return unsolvedCase
n = input()
ls = list(map(int, input().split()))
print(num_of_u_case(ls))


n = int(input())
a = list(map(int, input().split()))
total = 0
untreated = 0
for i in range(n):
	total += a[i]
	if total < 0 and a[i] == -1:
		untreated += 1
		total = 0
print(untreated)


n = int(input())
r = [int(x) for x in input().split()]
sums = 0
miss = 0
for i in r:
	if sums <= 0 and i == -1:
		miss += 1
	else:
		sums += i
print(miss)


n = int(input())
curoff = 0
untreated = 0
a = list(map(int, input().split()))[:n]
for i in a:
	if i > 0:
		curoff += i
	elif curoff < 1:
		untreated += 1
	else:
		curoff -= 1
print(untreated)


n = int(input())
list1 = [int(x) for x in input().split(' ')]
p = 0
c = 0
for i in range(n):
	if list1[i] > 0:
		p += list1[i]
	elif p > 0:
		p -= 1
	else:
		c += 1
print(c)


q = int(input())
a = list(map(int, input().split()))
ans = 0
police = 0
for i in range(q):
	if a[i] < 0:
		if police > 0:
			police -= 1
		else:
			ans += 1
	elif a[i] > 0:
		police += a[i]
print(ans)


n = int(input())
num = list(map(int, input().split(' ')))
sum = 0
count = 0
for i in range(n):
	sum = sum + num[i]
	if sum <= -1:
		count = count + 1
		sum = 0
	else:
		continue
print(count)


n = int(input())
a = list(map(int, input().split()))
pres = 0
suma = 0
for i in range(n):
	if a[i] < 0 and suma == 0:
		pres += 1
	elif a[i] < 0 and suma != 0:
		suma -= 1
	elif a[i] > 0:
		suma += a[i]
print(pres)


n = int(input())
ev = list(map(int, input().strip().split(' ')))
p = 0
s = 0
for i in ev:
	if s < 0 and i > 0:
		p += abs(s)
		s = 0
	s += i
if s < 0:
	p += abs(s)
print(p)


input()
a = list(map(int, input().split()))
cr = 0
re = 0
t = 0
for i in range(len(a)):
	if a[i] == -1 and t == 1:
		re -= 1
		if re == 0:
			t = 0
	elif a[i] == -1:
		cr += 1
	else:
		re += a[i]
		t = 1
print(cr)


nCases = int(input())
cases = [int(j) for j in input().split()]
sump = 0
crimes = 0
for i in cases:
	if i == -1:
		if sump > 0:
			sump -= 1
		else:
			crimes += 1
	else:
		sump += i
print(crimes)


def solve(events):
	u = 0
	p = 0
	for event in events:
		if event == -1:
			if p > 0:
				p -= 1
			else:
				u += 1
		else:
			p += event
	return u
n = int(input())
events = map(int, input().split(' '))
print(solve(events))


(t, crimes, polices) = (int(input()), 0, 0)
for i in list(map(int, input().rstrip().split())):
	if i == -1:
		if polices:
			polices -= 1
		else:
			crimes += 1
	else:
		polices += i
print(crimes)


n = int(input())
a = list(map(int, input().split()))
prestuplenie = 0
policai = 0
for i in a:
	if i < 0 and policai <= 0:
		prestuplenie += 1
	elif i < 0 and policai > 0:
		policai -= 1
	elif i > 0:
		policai += i
print(prestuplenie)


_ = input()
policeman = 0
unchecked = 0
for event in input().split():
	if event == '-1' and policeman:
		policeman -= 1
	elif event == '-1':
		unchecked += 1
	else:
		policeman += int(event)
print(unchecked)


n = int(input())
a = input()
cnt = 0
crime = 0
police = 0
a = a.split()
for i in a:
	pc = int(i)
	if pc > 0:
		police = police + pc
	elif pc == -1:
		if police > 0:
			police = police - 1
		else:
			crime = crime + 1
print(crime)


n = int(input())
s = list(map(int, input().split()))
count1 = 0
count2 = 0
ans = 0
a = 0
for i in s:
	count2 = 0
	if s[a] < 0:
		count2 += 1
		a += 1
		if count2 > count1:
			ans += 1
		else:
			count1 -= 1
	else:
		count1 += s[a]
		a += 1
print(ans)


number_of_events = int(input())
polices_and_crimes = list(map(int, input().strip().split()))[:number_of_events]
polices = 0
result = 0
for i in range(number_of_events):
	if polices_and_crimes[i] > 0:
		polices += polices_and_crimes[i]
	elif polices > 0:
		polices -= 1
	else:
		result += 1
print(result)


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
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
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
n = int(z())
ans = 0
t = 0
for i in zzz():
	if i != -1:
		t += i
		continue
	else:
		t -= 1
	if t < 0:
		ans += 1
		t = 0
print(ans)


n = int(input())
l = [int(x) for x in input().split(' ')]
(count, sm) = (0, 0)
for x in l:
	sm += x
	if sm < 0:
		count += 1
		sm = 0
print(count)


n = int(input())
x = [int(i) for i in input().split()]
jlh = 0
for i in x[::-1]:
	jlh = min(0, jlh + i)
print(-jlh)


n = int(input())
events = list(map(int, input().split()))
(police, crime) = (0, 0)
for i in events:
	if police == 0 and i == -1:
		crime += 1
	else:
		police += i
print(crime)


n = int(input())
chronology = list(map(int, input().split()))
police = 0
untreated = 0
for i in chronology:
	if i > 0:
		police += i
	elif i < 0:
		if police + i < 0:
			untreated += 1
		else:
			police -= 1
print(untreated)


n = int(input())
g = list(map(int, input().split()))[::-1]
r = 0
for i in g:
	if i == -1:
		r -= 1
	elif r < 0:
		r = min(0, r + i)
print(-r)


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


n = int(input())
ipt = [int(x) for x in input().split()]
counter = 0
opt = 0
for (i, val) in enumerate(ipt):
	counter += val
	if counter < 0:
		opt += 1
		counter = 0
print(opt)


n = int(input())
crime = 0
x = 0
(*l,) = map(int, input().split())
for i in l:
	if i < 0:
		crime += 1
		if x >= 1:
			crime -= 1
			x -= 1
	if i > 0:
		x += i
print(crime)


n = int(input())
a = list(map(int, input().split()))
c = 0
k = 0
for i in a:
	if i > 0:
		c += i
	elif i == -1:
		c += i
		if c < 0:
			k += 1
			c = 0
print(k)


import math
from collections import Counter

def get(f):
	return map(f, input().split())

def divides(a, b):
	return a % b == 0

def main():
	n = int(input())
	vals = get(int)
	crimes = 0
	cops = 0
	for i in vals:
		if i < 0:
			if cops == 0:
				crimes += 1
			else:
				cops -= 1
		else:
			cops += i
	print(crimes)
main()


o_case = int(input())
act = list(map(int, input().split()))
case_ind = 0
sol = 0
for x in act:
	if case_ind == 0 and x == -1:
		sol += 1
	else:
		case_ind += int(x)
print(sol)


x = 0
a = int(input())
b = [int(i) for i in input().split()]
for i in range(a):
	if b[i] < 0:
		x += 1
	if b[i] >= 0:
		if i >= 0 and i < a - 1:
			b[i + 1] = b[i + 1] + b[i]
print(x)


n = int(input())
arr = [int(i) for i in input().split()]
x = 0
c = 0
for a in arr:
	x += a
	if x < 0:
		c += 1
		x = 0
print(c)


events = int(input())
e = [int(i) for i in input().split()]
police = 0
c = 0
for i in e:
	if i > 0:
		police += i
	elif police != 0:
		police -= 1
	else:
		c += 1
print(c)


n = int(input())
crimes = 0
police_recruits = 0
list_ = list(map(int, input().split()))
for i in list_:
	if i == -1:
		crimes -= 1
		if police_recruits > 0:
			crimes += 1
			police_recruits -= 1
	else:
		police_recruits += i
print(abs(crimes))


n = input()
n = int(n)
l = input().split()
av = 0
ans = 0
for i in l:
	i = int(i)
	if i != -1:
		av += i
	elif av == 0:
		ans += 1
	else:
		av -= 1
print(ans)


n = int(input())
events = list(map(int, input().split()))
(answer, manpower) = (0, 0)
for i in events:
	if i == -1 and manpower == 0:
		answer += 1
	elif i == -1 and manpower != 0:
		manpower -= 1
	else:
		manpower += i
print(answer)


def police(n):
	inp = list(map(int, input().strip().split()))
	counter_men = 0
	counter_crimes = 0
	i = 0
	for i in range(len(inp)):
		if inp[i] > 0:
			counter_men += inp[i]
		elif inp[i] < 0 and counter_men > 0:
			counter_men = counter_men - 1
		elif inp[i] < 0 and counter_men == 0:
			counter_crimes += 1
	return counter_crimes
n = int(input())
print(police(n))


n = int(input())
arr = [int(x) for x in input().strip().split()]
(count, k) = (0, 0)
for i in range(0, n):
	if arr[i] != -1:
		k += arr[i]
	elif k == 0 and arr[i] == -1:
		count += 1
	elif arr[i] == -1:
		k -= 1
print(count)


n = int(input())
s = [int(i) for i in input().split()]
c = 0
police = 0
crime = 0
for i in range(n):
	if s[i] > 0:
		police += s[i]
	if s[i] == -1:
		if police > 0:
			police -= 1
		else:
			crime += 1
print(crime)


x = input()
x = [int(y) for y in input().split()]
z = 0
c = 0
for n in x:
	if n >= 0:
		z += n
	elif z > 0:
		z -= 1
	else:
		c += 1
print(c)


n = int(input())
l = list(map(int, input().split()))
i = 0
p = 0
c = 0
while i < len(l):
	if l[i] >= 1:
		p += l[i]
	elif l[i] == -1:
		c += 1
		if p >= 1:
			c -= 1
			p -= 1
	i += 1
print(c)


n = int(input())
l = [int(i) for i in input().split()]
(total, count) = (0, 0)
for i in l:
	if i < 0:
		if total - 1 == 0 or total - 1 > 0:
			total -= 1
			continue
		else:
			count += 1
	else:
		total += i
print(count)


def getInts():
	return [int(s) for s in input().split()]

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

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
import collections as c

def solve():
	N = getInt()
	A = getInts()
	ret = 0
	officers = 0
	for j in range(N):
		x = A[j]
		if x == -1:
			if officers > 0:
				officers -= 1
			else:
				ret += 1
		else:
			officers += x
	return ret
ans = solve()
print(ans)


input()
l = map(int, input().split())
p = 0
c = 0
for i in l:
	if i == -1:
		if p > 0:
			p -= 1
		else:
			c += 1
	else:
		p += i
print(c)


count = 0
a = 0
z = int(input())
x = list(map(int, input().split()))
for c in range(len(x)):
	if x[c] == -1 and a == 0:
		count += 1
	else:
		a = a + x[c]
print(count)


n = int(input())
v = list(map(int, input().split()))
ret = 0
p = 0
for i in v:
	if i == -1:
		if p > 0:
			p -= 1
		else:
			ret += 1
	else:
		p += i
print(ret)


n = int(input())
a = list(map(int, input().split()))
p = 0
ans = 0
i = 0
while i < n:
	if a[i] < 0:
		if p == 0:
			ans += 1
		else:
			p -= 1
	else:
		p += a[i]
	i += 1
print(ans)


n = int(input())
crimes = list(map(int, input().split()))
count = 0
police = 0
for c in crimes:
	police += c
	if police < 0:
		count += 1
		police = 0
print(count)


n = int(input())
a = list(map(int, input().split()))
unsolved_crimes = 0
police_officers = 0
crimes = 0
m = len(a)
for i in range(m):
	if crimes == 0 and a[i] == -1 and (police_officers == 0):
		unsolved_crimes += 1
	elif a[i] == -1:
		police_officers -= 1
	if a[i] > 0:
		police_officers += a[i]
print(unsolved_crimes)


n = int(input())
a = [i for i in map(int, input().split())]
police = 0
ans = 0
i = 0
while i < n:
	if a[i] >= 0:
		police += a[i]
	elif police + a[i] >= 0:
		police += a[i]
	else:
		ans -= a[i] + police
		police = 0
	i += 1
print(ans)


n = int(input())
polices = 0
untreatedCases = 0
arr = list(map(int, input().rstrip().split()))
for i in arr:
	if i == -1:
		if polices > 0:
			polices -= 1
		else:
			untreatedCases += 1
	else:
		polices += i
print(untreatedCases)


def func(l):
	untreated = 0
	available = 0
	for i in l:
		if i == -1:
			if available > 0:
				available -= 1
			else:
				untreated += 1
		else:
			available += i
	return untreated
n = int(input())
l = list(map(int, input().split()))
print(func(l))


n = int(input())
x = list(map(int, input().split()))
hired = unrated = 0
for el in x:
	if el > 0:
		hired += el
		continue
	if hired > 0 and el < 0:
		hired -= 1
		continue
	if el < 0:
		unrated += 1
print(unrated)


n = int(input())
v = [int(x) for x in input().split()]
count = 0
untreated = 0
for c in v:
	count += c
	if count < 0:
		count = 0
		untreated += 1
print(untreated)


n = int(input())
L = list(map(int, input().split()))
police = 0
thief = 0
crimes = 0
for i in range(n):
	if L[i] == -1 and police == 0:
		crimes += 1
	elif L[i] == -1:
		police -= 1
	else:
		police += L[i]
print(crimes)


n = int(input())
s = input().split()
s = [int(x) for x in s]
d = 0
ans = 0
for i in s:
	if i < 0:
		if d != 0:
			d -= 1
		else:
			ans += 1
	if i > 0:
		d += i
print(ans)


officer = 0
crime = 0
occ = 0
number_crime = int(input())
crime_officer_1 = list(input().split())
crime_officer_2 = []
for i in crime_officer_1:
	crime_officer_2.append(int(i))
for i in crime_officer_2:
	if i > 0:
		officer = officer + i
	elif officer < 1:
		crime = crime + 1
	else:
		officer = officer - 1
print(crime)


import sys
n = int(sys.stdin.readline()[:-1])
crime_hire = [int(num) for num in sys.stdin.readline()[:-1].split()]
output = 0
officers = 0
crimes = 0
for num in crime_hire:
	if num == -1:
		crimes += 1
		if officers == 0:
			output += 1
		else:
			officers -= 1
	else:
		officers += num
print(output)


n = int(input())
lst = list(map(int, input().split()))
sm = 0
c = 0
for i in lst:
	if i == -1 and sm == 0:
		c += 1
	elif i == -1 and sm > 0:
		sm += i
	else:
		sm += i
print(c)


n = int(input())
a = list(map(int, input().split()))
b = 0
count = 0
for i in range(n):
	if a[i] > 0:
		b += a[i]
	elif a[i] < 0 and b > 0:
		b += a[i]
	else:
		count += a[i]
print(abs(count))


n = int(input())
A = input()
B = []
for i in A.split():
	B.append(int(i))
sum = 0
count = 0
for j in range(0, n):
	if B[j] > 0:
		count = count + B[j]
	elif count == 0:
		sum = sum + 1
	else:
		count = count - 1
print(sum)


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


ip = int(input())
n_ip = list(map(int, input().split(' ')))
hired = untreated = 0
for i in range(ip):
	if n_ip[i] > 0:
		hired = hired + n_ip[i]
		continue
	if n_ip[i] < 0 and hired > 0:
		hired = hired - 1
		continue
	if n_ip[i] < 0:
		untreated = untreated + 1
print(untreated)


n = int(input())
l = list(map(int, input().split()))
h = 0
untrated = 0
for i in l:
	if i > 0:
		h += i
	elif h > 0:
		h -= 1
	else:
		untrated += 1
print(untrated)


n = int(input())
arr = list(map(int, input().split()))
c = 0
p = 0
for i in arr:
	if i > 0:
		p += i
	else:
		i = abs(i)
		if p > 0:
			c += i - min(p, i)
			p -= min(p, i)
		else:
			c += i
print(abs(c))


n = int(input())
arr = list(map(int, input().split()))
c = 0
ans = 0
for i in arr:
	c += i
	if c < 0:
		ans += 1
		c = 0
print(ans)


n = input()
event = list(map(int, input().split()))
R = 0
C = 0
for i in range(len(event)):
	if event[i] != -1:
		R = R + event[i]
	elif R != 0:
		R -= 1
	else:
		C = C - 1
print(abs(C))


k = input()
str = input().split()
count = 0
p = 0
a = 0
k = 0
for n in str:
	m = int(n)
	if m >= 0:
		p = p + m
	elif m < 0:
		if p > 0:
			p = p - 1
		elif p == 0:
			k = k + 1
print(k)


n = int(input())
ai = list(map(int, input().split()))
num = 0
ans = 0
for i in range(n):
	num += ai[i]
	ans += num < 0
	num = max(0, num)
print(ans)


n = input()
crime = 0
policeman = 0
for el in map(int, input().split()):
	if el > 0:
		policeman += el
	elif policeman > 0:
		policeman -= 1
	else:
		crime += 1
print(crime)


n = int(input())
events = input().split()
for i in range(n):
	events[i] = int(events[i])
cops = 0
untreated = 0
for i in range(n):
	k = events[i]
	if k < 0:
		if cops > 0:
			cops -= 1
		else:
			untreated += 1
	else:
		cops += k
print(untreated)


n = int(input())
s = [int(x) for x in input().split()]
x = 0
y = 0
for i in s:
	x += i
	if x == -1:
		x = 0
		y += 1
print(y)


n = input()
s = list(map(int, input().split()))
ms = 0
cnt = 0
for i in s:
	if i == -1:
		if ms == 0:
			cnt += 1
		else:
			ms -= 1
	else:
		ms += i
print(cnt)


(n, res, ans) = (int(input()), 0, 0)
a = list(map(int, input().split()))
for x in a:
	if x > 0 or (x < 0 and res >= -x):
		res += x
	else:
		res = 0
		ans += -x
print(ans)


n = int(input())
sob = list(map(int, input().split()))
police = 0
prest = 0
for i in sob:
	if i > 0:
		police += i
	elif i < 0:
		if police <= 0:
			prest += 1
		else:
			police -= 1
print(prest)


n = int(input())
events = list(map(int, input().split()))
reserve = 0
crime = 0
for event in events:
	if event == -1 and reserve == 0:
		crime += 1
	elif event == -1:
		reserve -= 1
	else:
		reserve += event
print(crime)


n = int(input())
a = [int(i) for i in input().split()]
num = 0
res = 0
for i in range(n):
	if a[i] == -1 and num == 0:
		res += 1
	elif a[i] == -1 and num > 0:
		if num - 1 < 0:
			num = 0
		else:
			num -= 1
	elif a[i] != -1:
		num += a[i]
print(res)


def main():
	n = int(input())
	ls = list(map(int, input().split()))
	c = 0
	p = 0
	for i in range(n):
		if ls[i] == -1 and p > 0:
			p -= 1
		elif ls[i] == -1 and p <= 0:
			c += 1
		elif ls[i] <= 10:
			p += ls[i]
	print(c)
main()


n = int(input())
a = list(map(int, input().split()))
officers = 0
output = 0
for i in range(n):
	if a[i] > 0:
		officers += a[i]
	elif officers == 0:
		output += 1
	else:
		officers -= 1
print(output)


input()
events = map(int, input().split())
crimes = 0
i = 0
for e in events:
	i += e
	if i < 0:
		i = 0
		crimes += 1
print(crimes)


n = int(input())
events = [int(i) for i in input().split()]
police = 0
crime = 0
for i in range(n):
	if events[i] == -1:
		if police != 0:
			police -= 1
		else:
			crime += 1
	else:
		police += events[i]
print(crime)


n = int(input())
l = list(map(int, input().split()))
crimes = 0
recruit = 0
for i in range(n):
	if l[i] == -1:
		if recruit > 0:
			recruit -= 1
		else:
			crimes += 1
	else:
		recruit += l[i]
print(crimes)


n = int(input())
s = []
a = list(map(int, input().split()))
l = 0
for i in range(len(a)):
	try:
		if s[-1] == 1 and a[i] != -1:
			s.append(a[i])
		elif s[-1] == 1 and a[i] == -1:
			s.pop()
		elif s[-1] > 1 and a[i] == -1:
			s[-1] -= 1
		else:
			s.append(a[i])
	except:
		s.append(a[i])
for i in range(len(s)):
	if s[i] == -1:
		l += 1
print(l)


n = int(input())
nums = [int(x) for x in input().split()]
crimes = 0
police = 0
for num in nums:
	if num == -1:
		if police is 0:
			crimes += 1
		else:
			police -= 1
	else:
		police += num
print(crimes)


n = int(input())
l = []
x = input().split()
for i in range(n):
	a = x[i]
	l.append(a)
b = 0
c1 = 0
c2 = 0
for i in range(len(l)):
	if int(l[i]) < 0 and c2 == 0:
		c1 = int(c1) + 1
	else:
		c2 = int(c2) + int(l[i])
print(c1)


number_events = int(input())
events = [int(x) for x in input().split()]
unsolved_crimes = 0
availably_officers = 0
for elem in events:
	if elem == -1:
		if availably_officers == 0:
			unsolved_crimes += 1
		else:
			availably_officers -= 1
	else:
		availably_officers += elem
print(unsolved_crimes)


def proA(arr):
	ans = 0
	final = 0
	for i in arr:
		if i > 0:
			ans += i
		elif ans == 0:
			final += 1
		else:
			ans -= 1
	return final
t = int(input())
for i in range(1):
	arr = list(map(int, input().split()))
	print(proA(arr))


n = int(input())
times = [int(x) for x in input().split()]
p = 0
ans = 0
for time in times:
	if p == 0 and time == -1:
		ans += 1
	else:
		p += time
print(ans)


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(n,) = I()
a = I()
ans = 0
off = 0
for i in range(n):
	if a[i] == -1 and off:
		off -= 1
	elif a[i] == -1:
		ans += 1
	else:
		off += a[i]
print(ans)


n = int(input())
l = list(map(int, input().split()))
R = 0
crime = 0
for i in l:
	if i < 0:
		if R != 0:
			R -= 1
		else:
			crime += 1
	else:
		R += i
print(crime)


n = int(input())
events = [int(x) for x in input().split()]
hired = 0
crimes = 0
for i in range(n):
	if events[i] > 0:
		hired += events[i]
	elif hired > 0:
		hired += events[i]
	else:
		crimes += 1
print(crimes)


n = int(input())
l = [int(i) for i in input().split()]
h = 0
u = 0
for i in range(len(l)):
	if l[i] > 0:
		h = h + l[i]
	else:
		h = h + l[i]
		if h < 0:
			h = 0
			u = u + 1
print(u)


n = int(input())
a = list(map(int, input().split()))
countPolicemen = 0
countCrime = 0
for i in a:
	if i != -1:
		countPolicemen += i
	elif i == -1 and countPolicemen > 0:
		countPolicemen -= 1
	else:
		countCrime += 1
print(countCrime)


_ = input()
lst = input().split()
hired = 0
un = 0
for c in lst:
	if c == '-1' and hired == 0:
		un += 1
	elif int(c) > 0:
		hired += int(c)
	else:
		hired -= 1
print(un)


n = int(input())
l = list(map(int, input().split()))
s = 0
res = 0
for e in l:
	if e == -1:
		if s == 0:
			res += 1
		else:
			s -= 1
	else:
		s += e
print(res)


def policeRecruits():
	n = int(input())
	values = input().split()
	sum = 0
	count = 0
	for i in range(len(values)):
		if int(values[i]) > 0:
			sum += int(values[i])
		elif sum > 0:
			sum -= 1
		else:
			count += 1
	print(count)
policeRecruits()


n = int(input())
x = list(map(int, input().split()))
pr = 0
rab = 0
for i in x:
	if i > 0:
		rab += i
	elif i < 0 and rab > 0:
		rab -= 1
	else:
		pr += 1
print(pr)


n = int(input())
hired = 0
untrated = 0
a = list(map(int, input().split()))
for i in a:
	if i > 0:
		hired += i
	elif i < 0 and hired > 0:
		hired -= 1
	elif i < 0:
		untrated += 1
print(untrated)


n = int(input())
nums = list(map(int, input().split()))
currof = 0
untreated = 0
for i in range(len(nums)):
	if nums[i] > 0:
		currof += nums[i]
	elif currof < 1:
		untreated += 1
	else:
		currof -= 1
print(untreated)


n = int(input())
events = list(map(int, input().split(' ')))
policemans = 0
crimes = 0
for event in events:
	if event > 0:
		policemans += event
	elif policemans > 0:
		policemans -= 1
	else:
		crimes += 1
print(crimes)


n = int(input())
event = list(map(int, input().split()))
hir = 0
count = 0
for i in event:
	if i < 0:
		if hir == 0:
			count += 1
		else:
			hir += i
	else:
		hir += i
print(count)


n = int(input())
crime = list(map(int, input().split()))
officer = 0
solved = 0
un_solved = 0
for i in crime:
	if i > 0:
		officer = officer + i
	elif i == -1:
		if officer > 0:
			solved = solved + 1
			officer = officer - 1
		elif officer == 0:
			un_solved = un_solved + 1
print(un_solved)


input()
vals = input().split(' ')
(crimes, cops) = (0, 0)
for val in vals:
	val = int(val)
	if val > 0:
		cops += val
	elif cops > 0:
		cops -= 1
	else:
		crimes += 1
print(crimes)


n = int(input())
events = [int(x) for x in input().split()]
crimes = 0
officers = 0
for i in range(n):
	j = i + 1
	if events[i] >= 1:
		officers += events[i]
	if events[i] == -1 and officers != 0:
		officers -= 1
	elif events[i] == -1 and officers == 0:
		crimes += 1
print(crimes)


import sys

def main():
	sys_in = sys.stdin
	sys_out = sys.stdout
	n = int(sys_in.readline())
	occurrences = tuple(map(int, sys_in.readline().split()))
	pigs = []
	ans = 0
	s = 1
	for i in occurrences:
		if i > 0:
			s *= i
			while s > 0:
				pigs.append(1)
				s -= 1
			s += 1
		else:
			try:
				pigs.pop()
			except:
				ans += 1
	sys_out.write(f'{ans}')
main()


input()
b = [int(i) for i in input().split()]
(d, ans) = (0, 0)
for i in b:
	if i != -1:
		d += i
	else:
		if d == 0:
			ans += 1
		if d > 0:
			d -= 1
print(ans)


try:
	n = int(input())
	l = list(map(int, input().split()))
	h = 0
	i = 0
	for j in range(0, n):
		if l[j] > 0:
			h += l[j]
		elif h > 0:
			h = h - 1
		else:
			i += 1
		j += 1
	print(i)
except:
	pass


n = int(input())
unsolved = 0
ready = 0
arr = list(map(int, input().split()))
for i in arr:
	if i >= 1:
		ready += i
	elif i == -1 and ready == 0:
		unsolved += 1
	else:
		ready -= 1
print(unsolved)


n = int(input())
recruits = [int(i) for i in input().split(' ')]
untaken = 0
police = 0
for i in recruits:
	if i >= 1:
		police += i
	elif i < 0 and police > 0:
		police -= abs(i)
	elif i < 0 and police == 0:
		untaken += abs(i)
print(untaken)


n = int(input())
a = [int(x) for x in input().split()]
(off, out) = (0, 0)
for i in range(n):
	if a[i] > 0:
		off += a[i]
	elif a[i] == -1 and off > 0:
		off -= 1
	else:
		out += 1
print(out)


n = int(input())
c = list(map(int, input().split(' ')))
left = 0
police_inhand = 0
for x in c:
	if x < 0 and police_inhand == 0:
		left += x
	elif x > 0:
		police_inhand += x
	elif x < 0 and police_inhand > 0:
		police_inhand += x
print(left * -1)


n = int(input())
N = [int(num) for num in input().split(' ', n - 1)]
i = x = X = 0
while i < n:
	if N[i] > 0:
		x = x + N[i]
	elif x > 0:
		x = x + N[i]
	else:
		X += 1
	i += 1
print(X)


__copyright__ = ''
__author__ = 'Son-Huy TRAN'
__email__ = 'sonhuytran@gmail.com'
__doc__ = ''
__version__ = '1.0'

def count_untreated_crimes(events: list) -> int:
	untreated = 0
	recruted = 0
	for event in events:
		if event > 0:
			recruted += event
		elif event == -1:
			if recruted <= 0:
				untreated += 1
			else:
				recruted -= 1
	return untreated

def main() -> int:
	input()
	events = [int(word) for word in input().split()]
	print(count_untreated_crimes(events))
	return 0
exit(main())


n = int(input())
free = 0
events = map(int, input().split())
cnt = 0
for e in events:
	if e == -1:
		if free == 0:
			cnt += 1
		else:
			free -= 1
	else:
		free += e
print(cnt)


N = int(input())
crimes = list(map(int, input().split()))
sol = hired = 0
for el in crimes:
	if el > 0:
		hired += el
		continue
	if hired > 0 and el < 0:
		hired -= 1
		continue
	if el < 0:
		sol += 1
print(sol)


x = input()
l = [int(x) for x in input().split(' ')]
o = 0
u = 0
for i in l:
	if i != -1:
		o += i
	elif o == 0:
		u += 1
	else:
		o -= 1
print(u)


n = int(input())
arr = [int(x) for x in input().split()]
count = 0
police = 0
for i in arr:
	if i > 0:
		police += i
	elif police <= 0:
		count += 1
	else:
		police -= 1
print(count)


n = int(input())
l = list(map(int, input().split()))
c = 0
p = 0
for i in range(n):
	u = 0
	if l[i] == -1:
		u = u + 1
	if l[i] != -1:
		p = p + l[i]
	if p - u < 0:
		c = c + 1
	if p - u >= 0:
		p = p - u
print(c)


(n, events) = (int(input()), list(map(int, input().split())))
(police, crimes) = (0, 0)
for e in events:
	if e >= 0:
		police += e
	else:
		police -= 1
		crimes += police < 0
		police = max(0, police)
print(crimes)


n = int(input())
cron = [int(x) for x in input().split()]
free = 0
untreat = 0
for i in cron:
	if i > 0:
		free += i
	elif free > 0:
		free -= 1
	else:
		untreat += 1
print(untreat)


n = int(input())
a = list(map(int, input().split()[:n]))
s = cnt = 0
for i in a:
	s += i
	if s < 0:
		cnt += 1
		s = 0
print(cnt)


number_events = int(input())
events = list(map(int, input().split()))
crime = 0
hire = 0
for event in events:
	if event > 0:
		hire += event
	elif hire > 0:
		hire -= 1
	else:
		crime += 1
print(crime)


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


n = int(input())
timeList = list(map(int, input().split()))
manpower = 0
crimes = 0
for event in timeList:
	if event > 0:
		manpower += event
	elif manpower > 0:
		manpower -= 1
	else:
		crimes += 1
print(crimes)


n = int(input())
a = [int(x) for x in input().split()]
crimes = 0
police = 0
for i in a:
	if i == -1 and police == 0:
		crimes += 1
	elif i == -1 and police > 0:
		police -= 1
	else:
		police += i
print(crimes)


a = 0
x = 0
b = int(input())
c = input().split()
for i in c:
	if i[0] != '-':
		x += int(i)
	elif x != 0:
		x -= 1
	else:
		a += 1
print(a)


n = int(input())
events = input().split()
police = 0
crime = 0
a = []
for i in events:
	a.append(int(i))
for i in a:
	if i > 0:
		police = police + i
	elif i < 0 and police == 0:
		crime = crime + 1
	elif i < 0 and police > 0:
		police = police - 1
print(crime)


input()
nums = list(map(int, input().split()))
p = t = 0
for num in nums:
	if num < 0 and p + num < 0:
		t += 1
	elif num < 0:
		p -= 1
	elif num > 0:
		p += num
print(t)


n = int(input())
li = list(map(int, input().split()))
sum = 0
count = 0
for i in range(len(li)):
	sum += li[i]
	if li[i] < 0 and sum < 0:
		count += 1
	if sum <= 0:
		sum = 0
print(count)


n = int(input())
arr = list(map(int, input().split()))
p = 0
res = 0
for i in range(n):
	if p == 0 and arr[i] == -1:
		res += 1
	elif p > 0 and arr[i] == -1:
		p -= 1
	elif arr[i] != -1:
		p += arr[i]
print(res)


from sys import stdin
_input = stdin.readline
_int = int

def solution():
	n = _int(_input())
	cops = 0
	ans = 0
	for current in [_int(i) for i in _input().split()]:
		if current > 0:
			cops += current
		elif cops == 0:
			ans += 1
		else:
			cops -= 1
	print(ans)
solution()


n = int(input())
a = map(int, input().split())
p = 0
c = 0
for i in a:
	if i > 0:
		p += i
	elif i + p >= 0:
		p = max(p - 1, 0)
	else:
		c += 1
print(c)


n = int(input())
a = [int(i) for i in input().split()]
h = 0
u = 0
for i in a:
	if i == -1 and h == 0:
		u += 1
	elif i == -1:
		h -= 1
	elif i > 0:
		h += i
print(u)


n = int(input())
s = list(map(int, input().split()))
h = 0
u = 0
if n == len(s):
	for i in s:
		if i > 0:
			h = h + i
		elif i < 0 and h > 0:
			h = h - 1
		elif i < 0 and h < 1:
			u = u + 1
print(u)


t = int(input())
nums = list(map(int, input().split()))
u = 0
f = 0
for x in nums:
	if x < 0:
		if f > 0:
			f = f + x
		else:
			u = u + abs(x)
	else:
		f = f + x
print(u)


n = int(input())
a = [int(x) for x in input().split()]
recruits = 0
crimes = 0
for x in a:
	if x < 0:
		if recruits > 0:
			recruits -= 1
		else:
			crimes += 1
	else:
		recruits += x
print(crimes)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
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 [int(x) for x in sys.stdin.readline().split()]

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 main():
	n = I()
	r = 0
	a = LI()
	t = 0
	for c in a:
		if c < 0:
			if t == 0:
				r += 1
			else:
				t -= 1
		else:
			t += c
	return r
print(main())


w = int(input())
a = 0
for i in list(map(int, input().split()))[::-1]:
	a = min(0, a + i)
print(abs(a))


n = int(input())
a = [int(x) for x in input().split()]
rec = 0
untreated = 0
for i in a:
	if i == -1:
		if rec == 0:
			untreated += 1
		else:
			rec -= 1
	else:
		rec += i
print(untreated)


n = int(input())
(p, q) = (0, 0)
for i in (int(j) for j in input().split()):
	p += i
	if p == -1:
		p = 0
		q += 1
print(q)


n = int(input())
crime = 0
police = 0
a = [int(x) for x in input().split()]
for i in range(n):
	if a[i] > 0:
		police += a[i]
	elif police > 0:
		police -= 1
	else:
		crime += 1
print(crime)


t = int(input())
q = input().split(' ')
n = 0
p = 0
s = 0
for i in range(t):
	if int(q[i]) < 0 and s == 0:
		n = n + 1
	elif int(q[i]) < 0 and s != 0:
		s = s - 1
	elif int(q[i]) > 0:
		if int(q[i]) <= 10:
			s = s + int(q[i])
		else:
			s = s + 10
print(n)


n = int(input())
L = [int(x) for x in input().split()]
num = 0
x = 0
for i in range(len(L)):
	x = x + L[i]
	if x < 0:
		num = num + 1
		x = 0
print(num)


input()
k = 0
for i in list(map(int, input().split()))[::-1]:
	k = min(0, k + i)
print(-k)


n = int(input())
listt = [None] * n
listt = list(map(int, input().split()))
noOfOff = 0
res = 0
for i in range(n):
	if listt[i] > 0:
		noOfOff = noOfOff + listt[i]
	if listt[i] < 0 and noOfOff <= 0:
		res = res + 1
	if listt[i] < 0 and noOfOff > 0:
		noOfOff = noOfOff - 1
print(res)


input()
s = list(map(int, input().split()))
p = u = 0
for i in s:
	if i == -1:
		if p:
			p -= 1
		else:
			u += 1
	else:
		p += i
print(u)


n = int(input())
string = input()
off = 0
untr = 0
nums = list(map(int, string.split()))
for i in nums:
	if i > 0:
		off += i
	elif i == -1:
		off = i + off
		if off < 0:
			untr += 1
			off = 0
print(untr)


n = input()
l = list(input().split())
l = [int(x) for x in l]
crimes = 0
men = 0
for i in l:
	if i < 0:
		if men == 0:
			crimes += 1
		else:
			men -= 1
	else:
		men += i
print(crimes)


input()
cops = 0
uncovered = 0
for i in [int(i) for i in input().split()]:
	if i == -1:
		if cops == 0:
			uncovered += 1
		else:
			cops -= 1
	else:
		cops += i
print(uncovered)


num = int(input())
arr = input()
arr = arr.split(' ')
available = 0
unattended = 0
for i in arr:
	if int(i) != -1:
		available = available + int(i)
	else:
		available = available - 1
		if available < 0:
			unattended += 1
			available = 0
print(unattended)


n = int(input())
cases = list(map(int, input().split()))
fails = 0
free_police = 0
for i in range(n):
	if cases[i] == -1:
		if free_police <= 0:
			fails += 1
		else:
			free_police -= 1
	else:
		free_police += cases[i]
print(fails)


n = int(input())
s = list(map(int, input().split()))
c = 0
ans = 0
for x in s:
	c += x
	if c < 0:
		ans += 1
		c = 0
print(ans)


n = int(input())
a = [int(j) for j in input().strip().split(' ')]
output = 0
for i in range(n):
	if a[i] > 0 and i != n - 1:
		a[i + 1] = a[i + 1] + a[i]
	elif a[i] < 0:
		output += 1
print(output)


n = [int(i) for i in input().split()][0]
a = [int(i) for i in input().split()]
ctr = 0
police = 0
for elem in a:
	if elem == -1:
		if police == 0:
			ctr += 1
		else:
			police -= 1
	else:
		police += elem
print(ctr)


n = int(input())
l = input().split()
i = 0
r = 0
k = 0
while i < n:
	l[i] = int(l[i])
	if l[i] == -1:
		if k > 0:
			k -= 1
		else:
			r += 1
	else:
		k += l[i]
	i += 1
print(r)


x = input()
fin = 0
bag = 0
str = input()
str = str.split()
for i in range(len(str)):
	str[i] = int(str[i])
	if str[i] < 0:
		str[i] += bag
		if bag == 0:
			continue
		bag -= 1
	else:
		bag += str[i]
for i in range(len(str)):
	str[i] = int(str[i])
	if str[i] < 0:
		fin += str[i] * -1
print(fin)


(policia, deputado) = (0, 0)
qtd = int(input())
crimes = map(int, input().split())
for crime in crimes:
	if crime < 0:
		if policia == 0:
			deputado += 1
		else:
			policia -= 1
	else:
		policia += crime
print(deputado)


a = int(input())
b = list(map(int, input().split()))
positivo = 0
negativo = 0
con = 0
for i in range(a):
	if b[i] > 0:
		positivo += b[i]
	elif positivo > 0:
		positivo -= 1
	else:
		con += 1
print(con)


n = int(input())
l = list(map(int, input().split(' ')))
officers = 0
untreated = 0
for el in l:
	if el == -1 and officers == 0:
		untreated += 1
	elif el == -1 and officers != 0:
		officers -= 1
	elif el >= 0:
		officers += el
print(untreated)


n = int(input())
a = [int(x) for x in input().split()]
(s, c) = (0, 0)
for i in a:
	if s or i > 0:
		s += i
	else:
		c += 1
print(c)


def main():
	b = int(input())
	vals = [int(v) for v in input().split()]
	cur = 0
	r = 0
	for v in vals:
		if v == -1:
			if cur > 0:
				cur -= 1
			else:
				r += 1
		else:
			cur += v
	print(r)
main()


from itertools import product
from math import ceil

def binary_table(string_with_all_characters, length_to_make):
	return [''.join(x) for x in product(string_with_all_characters, repeat=length_to_make)]

def all_possible_substrings(string):
	return [int(string[i:j]) for i in range(len(string)) for j in range(i + 1, len(string) + 1)]

def number_of_substrings(length):
	return int(length * (length + 1) / 2)

def is_prime(num):
	for i in range(2, num):
		if num / i == int(num / i) and num != i:
			return False
	return True
num = int(input())
array = list(map(int, input().split()))
vanish = 0
officers = 0
for i in array:
	if i == -1 and officers == 0:
		vanish += 1
	elif i == -1 and officers > 0:
		officers -= 1
	elif i:
		officers += i
print(vanish)


n = int(input())
s = list(map(int, input().split()))
crimes = 0
policemans = 0
not_opened_crimes = 0
for i in s:
	if i > 0:
		policemans = policemans + i
	if i < 0:
		if policemans > 0:
			policemans = policemans - 1
		elif policemans <= 0:
			not_opened_crimes += 1
print(not_opened_crimes)


num_events = input()
events = input().split()
num_hired = 0
num_crimes = 0
for event in events:
	event = int(event)
	if event != -1:
		num_hired = num_hired + event
	elif num_hired > 0:
		num_hired = num_hired - 1
	else:
		num_crimes = num_crimes + 1
print(num_crimes)


n = int(input())
listt = list(map(int, input().split()))
crime = 0
plus = 0
for i in listt:
	if plus == 0:
		if i < 0:
			crime += 1
		else:
			plus = 1
			police = i
	elif i > 0:
		police += i
	elif i < 0:
		if police > 0:
			police -= 1
		else:
			crime += 1
print(crime)


n = int(input())
a = map(int, input().split())
cnt = 0
sum = 0
for i in a:
	if i < 0 and sum <= 0:
		cnt += 1
	elif i > 0:
		sum += i
	elif i < 0 and sum > 0:
		sum += i
print(cnt)


ans = 0
r = 0
input()
l = list(map(int, input().split()))
for i in l:
	if i != -1:
		r += i
	elif r == 0:
		ans += 1
	else:
		r -= 1
print(str(ans), end='')


T = int(input())
l = list(map(int, input().split()))
even = 0
odd = 0
cri = 0
for i in range(len(l)):
	if l[i] < 0 and even == 0:
		cri += 1
	elif l[i] < 0 and even != 0:
		even -= 1
	elif l[i] > 0:
		even += l[i]
	else:
		pass
print(cri)


crimes = int(input())
st = []
occured = 0
li = [int(x) for x in input().split()]
off = 0
for i in li:
	if i == -1:
		if off == 0:
			occured += 1
		elif off > 0:
			off -= 1
	else:
		off += i
print(occured)


n = int(input())
list1 = list(map(int, input().split()))
police = 0
crime_untreated = 0
for i in range(n):
	if list1[i] == -1 and police == 0:
		crime_untreated += 1
	if list1[i] == -1 and police != 0:
		police -= 1
	if list1[i] != -1:
		police += list1[i]
print(crime_untreated)


input()
s = list(map(int, input().split()))
recruit = 0
untreated = 0
for i in s:
	if i < 0 and recruit == 0:
		untreated += 1
	else:
		recruit += i
print(untreated)


n = int(input())
li = list(map(int, input().split(' ')))
i = 0
c = 0
r = list()
while i < n:
	if li[i] > 0:
		c = c + li[i]
	elif c == 0:
		r.append(li[i])
	else:
		c = c + li[i]
	i = i + 1
print(len(r))


f = input()
crimes = 0
for i in list(map(int, input().split()))[::-1]:
	crimes = min(0, crimes + i)
print(-crimes)


input()
mas = [int(x) for x in input().split()]
x = 0
answ = 0
for i in mas:
	if i != -1:
		x += i
	elif x >= 1:
		x -= 1
	else:
		answ += 1
print(answ)


n = int(input())
text = input().split()
li = [int(i) for i in text]
(recruted, count) = (0, 0)
for i in li:
	if i == -1 and recruted == 0:
		count += 1
	elif i == -1 and recruted != 0:
		recruted -= 1
	else:
		recruted += i
print(count)


n = int(input())
a = list(map(int, input().split()))
c = 0
res = 0
for i in range(n):
	if a[i] == -1:
		if c > 0:
			c = c - 1
		else:
			res = res + 1
	else:
		c = c + a[i]
print(res)


temp = input()
data = [int(i) for i in input().split()]
police = 0
crime = 0
for i in data:
	if i == -1:
		if police > 0:
			police -= 1
		else:
			crime += 1
	else:
		police += i
print(crime)


available = 0
unchecked = 0
n = input()
array = input().split()
for i in array:
	i = int(i)
	if i == -1 and available == 0:
		unchecked += 1
	elif i == -1:
		available -= 1
	else:
		available += i % 11
print(unchecked)


input()
events = input().split(' ')
officers = crime = 0
for i in events:
	if i != '-1':
		officers += int(i)
	elif officers > 0:
		officers -= 1
	else:
		crime += 1
print(crime)


i = int(input())
j = list(map(int, input().split()))
c = 0
crimes = 0
officer = 0
for a in j:
	if a > 0:
		officer += a
	elif officer > 0:
		officer -= 1
	else:
		crimes += 1
print(crimes)


n = int(input())
lis = list(map(int, input().split()))
poscount = negcount = dupcount = 0
for i in lis:
	if i > 0:
		poscount = poscount + i
	else:
		dupcount = poscount + i
		if dupcount < 0:
			negcount = negcount + dupcount
			poscount = 0
		else:
			poscount = dupcount
print(-1 * negcount)


def untreated_crimes(events):
	crimes = 0
	officer_count = 0
	for event in events:
		if event > 0:
			officer_count += event
		elif officer_count > 0:
			officer_count -= 1
		else:
			crimes += 1
	return crimes
n = int(input())
print(untreated_crimes(list(map(int, input().split()))))


n = int(input())
l = [int(i) for i in input().split()]
r = 0
c = 0
for i in l:
	if i == -1:
		if c + i < 0:
			r += 1
			c = 0
		else:
			c -= 1
	else:
		c += i
print(r)


input()
s = list(map(int, input().split(' ')))
ans = 0
current = 0
for x in s:
	if current == 0 and x == -1:
		ans += 1
	elif current > 0 or x > 0:
		current += x
print(ans)


n = int(input())
ip = input()
event = []
ev = ip.split(' ')
event = list(map(lambda x: int(x), ev))
av = 0
op = 0
for i in event:
	if i > 0:
		av = av + i
	else:
		av = av - 1
		if av < 0:
			op = op + 1
			av = av + 1
print(op)


n = int(input())
arr = list(map(int, input().split()))
(neg, pos) = (0, 0)
count = 0
for i in range(n):
	if arr[i] == -1:
		neg += 1
	else:
		pos += arr[i]
	if neg > pos:
		count += neg - pos
		neg = 0
		pos = 0
print(count)


num = int(input())
line = [int(x) for x in input().split()]
num_police = 0
num_untreated = 0
for i in range(num):
	if line[i] == -1 and num_police == 0:
		num_untreated += 1
	elif line[i] == -1 and num_police > 0:
		num_police -= 1
	elif line[i] != -1:
		num_police += line[i]
print(num_untreated)


num_events = int(input())
list1 = [int(x) for x in input().split()]
crimes = 0
police = 0
untreated = 0
for event in list1:
	if event == -1:
		if police >= 1:
			police -= 1
		else:
			crimes += 1
			untreated += 1
	else:
		police += event
print(untreated)


n = int(input())
c = map(int, input().split())
x = 0
t = 0
for i in c:
	x += i
	if x < 0:
		t += 1
		x = 0
print(t)


input()
l = map(int, input().split())
officers = 0
crimes = 0
for i in l:
	if i == -1:
		if officers:
			officers -= 1
		else:
			crimes += 1
	else:
		officers += i
print(crimes)


(avlCops, result) = [0, 0]
n = input()
crimes = list(map(int, input().split()))
for crime in crimes:
	if crime > 0:
		avlCops += crime
	elif avlCops:
		avlCops += crime
	else:
		result += 1
print(result)


n = int(input())
crime = 0
police = 0
untreaded = 0
arr = list(map(int, input().split()))
for i in range(n):
	if arr[i] == -1:
		crime += 1
		if police > 0:
			crime = crime - 1
			police -= 1
	elif arr[i] > 0:
		police += arr[i]
print(crime)


value = int(input())
values = input()
values = values.split()
values = [int(i) for i in values]
sum = 0
count = list()
for i in values:
	sum = sum + i
	count.append(sum)
print(abs(min(min(count), 0)))


n = int(input())
(c, t) = (0, 0)
l = list(map(int, input().split()))
for i in l:
	t += i
	if t < 0:
		t = 0
		c += 1
print(c)


x = int(input())
y = [int(a) for a in input().split()]
a = 0
b = 0
for i in y:
	if i == -1:
		if b > 0:
			b -= 1
		else:
			a += 1
	else:
		b += i
print(a)


n = int(input())
a = list(map(int, input().split()))
sv = 0
ans = 0
for i in range(n):
	if a[i] > 0:
		sv += a[i]
	else:
		k = -a[i]
		if k <= sv:
			sv -= k
		else:
			ans += k - sv
			sv = 0
print(ans)


n = int(input())
d = input()
d = d.split(' ')
un = 0
po = 0
for x in d:
	if int(x) == -1:
		if po > 0:
			po -= 1
		else:
			un += 1
	else:
		po += int(x)
print(un)


n = int(input())
l = list(map(int, input().split()))
kn = 0
kp = 0
for i in range(n):
	if l[i] == -1:
		if kp >= 1:
			kp = kp - 1
		else:
			kn = kn + 1
	else:
		kp = kp + l[i]
print(kn)


n = int(input())
a = list(map(int, input().split()))
su = 0
cnt = 0
for x in a:
	if x > 0:
		su += x
	elif su > 0:
		su += x
	else:
		cnt += 1
print(cnt)


n = int(input())
l = list(map(int, input().strip().split()))
c = 0
s = 0
for i in l:
	if i == -1:
		if s > 0:
			s = s - 1
		else:
			c += 1
	else:
		s += i
print(c)


n = int(input())
L = list(map(int, input().split()))
r = 0
ans = 0
for i in range(n):
	if L[i] == -1:
		if r == 0:
			ans += 1
		else:
			r -= 1
	else:
		r += min(L[i], 10)
print(ans)


n = int(input())
query = input().split()
recruits = 0
unsolved = 0
for e in query:
	if e == '-1':
		if recruits > 0:
			recruits -= 1
		else:
			unsolved += 1
	else:
		recruits += int(e)
print(unsolved)


def main():
	n = int(input())
	s = list(map(int, input().split()))
	p = 0
	c = 0
	for i in s:
		if i > 0:
			p += i
		elif p == 0:
			c += 1
		else:
			p -= 1
	print(c)
main()


n = map(int, input())
array = list(map(int, input().split()))
ans = 0
p = 0
for i in range(len(array)):
	if array[i] > 0:
		p += array[i]
	elif array[i] == -1:
		if p > 0:
			p -= 1
		else:
			ans += 1
print(ans)


n = int(input())
list1 = list(map(int, input().split()))
count = 0
count1 = 0
for i in list1:
	if i < 0:
		if count > 0:
			count += i
		elif count == 0:
			count1 += abs(i)
	elif count < 0:
		count1 += abs(count)
		count = 0
	elif i > 0:
		count += i
print(count1)


n = int(input())
nums = [int(s) for s in input().split()]
count_crime = count_cops = 0
for x in nums:
	if x == -1:
		if count_cops > 0:
			count_cops -= 1
		else:
			count_crime += 1
	else:
		count_cops += x
print(count_crime)


n = int(input())
A = list(map(int, input().split()))
c = 0
res = 0
for i in A:
	if i > 0:
		c += i
	elif c == 0:
		res += 1
	else:
		c -= 1
print(res)


input()
data = [int(x) for x in input().split(' ')]
r = 0
h = 0
for i in data:
	if i > 0:
		h += i
	elif h == 0:
		r -= i
	else:
		h -= 1
print(r)


n = int(input())
a = [int(s) for s in input().split()]
(s, m) = (0, 0)
for i in range(n):
	s += a[i]
	if s < 0:
		m += abs(s)
		s = 0
print(m)


n = int(input())
d = list(map(int, input().split()))
(p, res) = (0, 0)
for i in d:
	if i == -1 and p > 0:
		p -= 1
	elif i == -1 and p == 0:
		res += 1
	else:
		p += i
print(res)


n = int(input())
l = list(map(int, input().split()))
positive = 0
number = 0
for i in range(len(l)):
	if l[i] >= 1:
		positive += l[i]
	elif positive >= 1:
		positive += l[i]
	else:
		number += 1
print(number)


n = int(input())
a = [int(i) for i in input().split()]
p = 0
ans = 0
for i in a:
	if i == -1 and p == 0:
		ans += 1
	elif i == -1 and p > 0:
		p -= 1
	if i != -1:
		p += i
print(ans)


n = int(input())
a = list(map(int, input().split()))
free = 0
unseen = 0
for i in range(n):
	if free == 0 and a[i] == -1:
		unseen += 1
	elif free > 0 and a[i] == -1:
		free -= 1
	else:
		free += a[i]
print(unseen)


a = input()
b = input()
b = b.split()
untreaded_crimes = 0
officers = list()
for i in range(int(a)):
	if int(b[i]) > 0:
		for j in range(int(b[i])):
			officers.insert(0, 1)
	elif len(officers) == 0:
		untreaded_crimes += 1
	else:
		officers.pop()
	i += 1
print(untreaded_crimes)


n = int(input())
events = [int(i) for i in input().split()]
d = 0
_min = 10 ** 9
for e in events:
	d += e
	_min = min(_min, d)
print(-min(0, _min))


n = int(input())
str = input()
c = 0
l = str.split(' ')
for i in range(0, len(l)):
	l[i] = int(l[i])
x = 0
i = 0
while i < n:
	if l[i] == -1 and x < 1:
		c += 1
	else:
		x += l[i]
	i += 1
print(c)


t = int(input())
values = list(map(int, input().split()))
police_counter = 0
crime_counter = 0
for value in values:
	if value == -1:
		if police_counter == 0:
			crime_counter += 1
		else:
			police_counter -= 1
	else:
		police_counter += value
print(crime_counter)


q = int(input())
p = list(map(int, input().split()))
crm = 0
plc = 0
for z in range(q):
	if p[z] >= 1:
		plc += int(p[z])
	elif p[z] == -1:
		if plc <= 0:
			crm += 1
		elif plc > 0:
			plc += -1
	if plc <= 0:
		plc = 0
print(crm)


n = int(input())
ln = input().split(' ')
free = 0
untreated = 0
for ev in ln:
	ev = int(ev)
	if ev > 0:
		free += ev
	elif free > 0:
		free += ev
	else:
		untreated += 1
print(untreated)


n = int(input())
a = input().split()
count = 0
c = 0
for i in range(0, n):
	if a[i] == '-1' and count == 0:
		c = c + 1
	elif a[i] != '-1' and count >= 0:
		count = count + int(a[i])
	else:
		count = count - 1
print(c)


from math import ceil, log, floor, sqrt
import math

def mod_expo(n, p, m):
	result = 1
	while p != 0:
		if p % 2 == 1:
			result = result * n % m
		p //= 2
		n = n * n % m
	return result

def get_string(n):
	s = 'codeforces'
	l = []
	res = ''
	flag = True
	if n == 1:
		return s
	for i in range(10):
		l.append(1)
	m = 1
	while flag:
		for i in range(10):
			m = m * (l[i] + 1) // l[i]
			l[i] += 1
			if m >= n:
				flag = False
				break
	for i in range(10):
		for j in range(l[i]):
			res += s[i]
	return res

def nc2(n):
	return n * (n + 1) / 2

def get_grain_count(n, l, m):
	print(l, n - nc2(l) - (m + l + 1))
	return n - nc2(l) - (m + l + 1)

def count_days(n, m):
	if n == 1:
		return 1
	value = 2 * (n - m - 1)
	l = ceil((-3 + sqrt(9 + 4 * value)) / 2)
	while get_grain_count(n, l, m) > 0:
		l += 1
	return m + l + 1

def get_count(n, arr):
	crimes = 0
	police = 0
	for i in range(n):
		if arr[i] > 0:
			police += arr[i]
		elif police:
			police -= 1
		else:
			crimes += 1
	return crimes
t = 1
while t:
	t = t - 1
	n = int(input())
	l = list(map(int, input().strip().split()))[:n]
	print(get_count(n, l))


n = int(input())
l = [int(i) for i in input().split()]
officer = 0
crime = 0
for i in range(n):
	if l[i] >= 0:
		officer += l[i]
	elif officer > 0:
		officer -= 1
	else:
		crime += 1
print(crime)


no = int(input())
x = list(map(int, input().split()))
police = 0
crime = 0
for i in x:
	if i < 0 and crime == 0:
		police += 1
	elif i < 0:
		crime -= 1
	else:
		crime += i
print(police)


n = int(input())
e = list(map(int, input().split()))
p = 0
c = 0
for i in e:
	if i != -1:
		p += i
	elif i == -1 and p == 0:
		c += 1
	elif i == -1:
		p -= 1
print(c)


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


n = int(input())
l = list(map(int, input().split()))
x = 0
y = 0
for i in l:
	if i > 0:
		x += i
	elif i == -1 and x != 0:
		x += i
	elif i == -1 and x == 0:
		y += i
print(abs(y))


def PoliceRecruits():
	n = int(input().strip())
	events = [*map(int, input().strip().split())]
	police = 0
	crime = 0
	for i in range(n):
		if events[i] == -1:
			crime += police == 0
			police -= police > 0
		else:
			police += events[i]
	return crime
a = PoliceRecruits()
print(a)


nStr = input()
n = int(nStr)
CrimeHireLs = input()
CrimeHireStr = CrimeHireLs.split()
currentMan = 0
untreated = 0
for i in range(n):
	currentMan = currentMan + int(CrimeHireStr[i])
	if currentMan < 0:
		untreated = untreated - currentMan
		currentMan = 0
print(untreated)


import sys
input = sys.stdin.readline
import math

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()
arr = inlt()
pol = 0
ans = 0
for i in range(len(arr)):
	if arr[i] == -1:
		if pol == 0:
			ans += 1
		else:
			pol -= 1
	else:
		pol += arr[i]
print(ans)


n = int(input())
str1 = list(map(int, input().split(' ')))
untreated = 0
officers = 0
for i in range(len(str1)):
	if str1[i] == -1:
		if officers == 0:
			untreated += 1
		elif officers > 0:
			officers -= 1
	elif str1[i] != -1:
		officers += str1[i]
print(untreated)


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


n = int(input())
var = input()
var = list(map(int, var.split()))
crimes = 0
police = 0
for i in range(len(var)):
	if var[i] != -1:
		police += var[i]
	elif var[i] == -1:
		if police <= 0:
			crimes += 1
		else:
			police -= 1
print(crimes)


def init():
	e_num = int(input())
	e_list = map(lambda x: int(x), input().split(' '))
	available_cops = 0
	unsolve_crimes = 0
	for e in e_list:
		if e == -1:
			if available_cops > 0:
				available_cops -= 1
			else:
				unsolve_crimes += 1
		elif e > 0:
			available_cops += e
	print(unsolve_crimes)
	return
init()


n = int(input())
events = list(map(int, input().split()))
ucrimes = 0
police = 0
for i in events:
	if i == -1 and police == 0:
		ucrimes += 1
	elif i == -1 and police != 0:
		police -= 1
	elif i > 0:
		police += i
print(ucrimes)


n = int(input())
s = list(map(int, input().strip().split()))
available = 0
needed = 0
untreated = 0
for i in range(0, len(s)):
	if s[i] > 0:
		available += s[i]
	else:
		needed += 1
		untreated = untreated + needed - (1 if available > 0 else 0)
		available = available - 1 if available > 0 else available
		needed -= 1
print(untreated)


n = int(input())
seq = list(map(int, input().split()))
avail_cops = 0
crimes = 0
for event in seq:
	if event > 0:
		avail_cops += event
	elif avail_cops == 0:
		crimes += 1
	else:
		avail_cops -= 1
print(crimes)


n = int(input())
(a, b) = (0, 0)
s = map(int, input().split())
for i in s:
	a += i
	if a < 0:
		b += 1
		a = 0
print(b)


n = int(input())
a = input().split()
c = 0
ans = 0
for i in range(n):
	if a[i] == '-1' and c == 0:
		ans += 1
	else:
		c += int(a[i])
print(ans)


n = int(input())
event = list(map(int, input().split()))
count = 0
police = 0
for i in event:
	if i == -1:
		count += max(1 - police, 0)
		if police != 0:
			police -= 1
	else:
		police += i
print(count)


n = int(input())
e = [int(i) for i in input().split()]
ap = 0
uc = 0
for i in e:
	if i > 0:
		ap += i
	else:
		x = ap + i
		if x > 0:
			ap = x
		else:
			ap = 0
			uc += -x
print(uc)


int(input())
st = []
cnt = 0
for i in list(map(int, input().split())):
	if i == -1:
		while st and st[-1] == 0:
			st.pop()
		if st:
			st[-1] -= 1
		else:
			cnt += 1
	else:
		st += [i]
print(cnt)


n = int(input())
l = [int(x) for x in input().split()]
a = 0
b = 0
for i in l:
	if i > 0:
		b += i
	elif b <= 0:
		a = a - i
	else:
		b += i
print(a)


n = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
s = 0
k = 0
for i in t:
	if i == -1:
		if s > 0:
			s -= 1
		else:
			k += 1
	else:
		s += i
print(k)


d = int(input())
p = [int(x) for x in input().split()]
(g, y) = (0, 0)
for i in p:
	g += i
	if g == -1:
		y += 1
		g = 0
print(y)


T_ON = 0
DEBUG_ON = 0
MOD = 998244353

def solve():
	n = read_int()
	polices = 0
	count = 0
	for e in read_ints():
		if e > 0:
			polices += e
		elif polices > 0:
			polices -= 1
		else:
			count += 1
	print(count)

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def dbg(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
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 read_int():
	return int(input())

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

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

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

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


n = int(input())
x = [int(i) for i in input().split()]
police = crime = 0
for i in x:
	if i == -1 and police < 1:
		crime += 1
	elif i == -1 and police >= 1:
		police -= 1
	elif i >= 1:
		police += i
print(crime)


input()
(c, p) = (0, 0)
for i in list(map(int, input().split())):
	if i == -1:
		c += 1
		if p > 0:
			c -= 1
			p -= 1
	elif i != -1:
		p += i
print(c)


n = int(input())
p = 0
t = 0
arr = [int(i) for i in input().split()][:n]
for i in arr:
	p += i
	if p < 0:
		t += 1
		p = 0
print(t)


n = int(input())
l = list(map(int, input().strip().split(' ')))
avlpolice = 0
crime = 0
for i in l:
	if i == -1:
		if avlpolice > 0:
			avlpolice = avlpolice - 1
		else:
			crime = crime + 1
	else:
		avlpolice = avlpolice + i
print(crime)


t = int(input())
events = list(map(int, input().split()))
police = 0
ans = 0
for i in events:
	if i == -1:
		police -= 1
	else:
		if police < 0:
			police = 0
		police += i
	if police < 0:
		ans += 1
print(ans)


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


import sys
n = int(input())
acts = list(map(str, input().split()))
number_polizes = 0
answer = 0
for act in acts:
	if act == '-1':
		if number_polizes == 0:
			answer += 1
		else:
			number_polizes -= 1
	else:
		number_polizes += int(act)
print(answer)


from sys import stdin
e = [map(int, x.rstrip().split()) for x in stdin.readlines()][1]
(p, c) = (0, 0)
for x in e:
	if x > 0:
		p += x
	elif p == 0:
		c += x
	else:
		p += x
print(-1 * c)


n = int(input())
evt = list(map(int, input().split()))
fp = 0
crm = 0
for i in evt:
	fp += i
	if fp < 0:
		crm += 1
		fp = 0
print(crm)


n = int(input())
lst = list(map(int, input().split()))
hired = 0
unsaved = 0
i = 0
while i < n:
	if lst[i] > 0:
		hired = hired + lst[i]
	else:
		hired = hired - 1
		if hired < 0:
			unsaved = unsaved + 1
			hired = 0
	i = i + 1
print(unsaved)


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


n = int(input())
l = [int(i) for i in input().split()]
c = 0
c1 = 0
for i in range(n):
	if l[i] > 0:
		c += l[i]
	elif c == 0:
		c1 += 1
	else:
		c -= 1
print(c1)


n = int(input())
c = input().split()
counter = 0
untreated = 0
for x in c:
	if int(x) > 0:
		counter += int(x)
	elif int(x) < 0 and counter == 0:
		untreated += 1
	else:
		counter -= 1
print(untreated)


n = int(input())
outcomes = list(map(int, input().split()))
count = 0
failures = 0
for i in range(len(outcomes)):
	count = count + outcomes[i]
	if count < 0:
		failures += 1
		count = 0
print(failures)


import sys
ret = 0
k = 0
c = sys.stdin.readline()
arr = sys.stdin.readline().split(' ')
for i in arr:
	i = int(i)
	if i > 0:
		k += i
	elif k > 0:
		k -= 1
	else:
		ret += 1
print(ret)


n = int(input())
tab = [int(x) for x in input().split()]
policemen = 0
crimes = 0
for x in tab:
	if x >= 0:
		policemen += x
	elif policemen > 0:
		policemen -= 1
	else:
		crimes += 1
print(crimes)


n = int(input())
a = [int(i) for i in input().split()]
police = 0
crime = 0
count = 0
for g in range(len(a)):
	if a[g] == -1:
		if police == 0:
			count += 1
		else:
			police -= 1
	else:
		police += a[g]
print(count)


n = int(input())
a = list(map(int, input().split()))
count = 0
police = 0
for i in a:
	if i == -1:
		if police > 0:
			police -= 1
		else:
			count += 1
	else:
		police += i
print(count)


n = int(input())
crime = list(map(int, input().split()))
f = 0
k = 0
for i in range(n):
	if crime[i] < 0 and k <= 0:
		f = f + 1
	if crime[i] < 0 and k > 0:
		k = k - 1
	if crime[i] > 0:
		k = k + crime[i]
print(f)


n = int(input())
l = list(map(int, input().strip().split()))
sum = 0
count = 0
for i in range(len(l)):
	if l[i] > 0:
		sum += l[i]
	elif sum > 0:
		sum -= 1
	else:
		count += 1
print(count)


n = int(input())
m = [int(i) for i in input().split()]
a = 0
c = 0
for i in range(n):
	c += m[i]
	if c < 0:
		a += 1
		c = 0
print(a)


_ = input()
timeline = [int(x) for x in input().strip().split(' ')]
people_force = 0
cnt = 0
for x in timeline:
	if x == -1 and people_force == 0:
		cnt += 1
	elif x > 0:
		people_force += x
	else:
		people_force -= 1
print(cnt)


count = int(input())
line = list(map(int, input().split(' ')))
crime = 0
policeman = 0
for i in range(count):
	if line[i] > 0:
		policeman += line[i]
	elif policeman == 0:
		crime += line[i]
	elif policeman >= line[i]:
		policeman += line[i]
		continue
	else:
		crime += line[i] + policeman
		policeman = 0
print(abs(crime))


try:
	n = int(input())
	arr = [int(ele) for ele in input().split()]
	ans = 0
	policeman = 0
	for i in arr:
		if i > 0:
			policeman += i
		elif i < 0:
			if policeman >= -i:
				policeman += i
			else:
				ans += -i
	print(ans)
except Exception:
	pass


n = int(input())
data = list(map(int, input().split()))
policeman = 0
crime = 0
for i in data:
	if i == -1 and policeman == 0:
		crime += 1
	elif i != -1:
		policeman += i
	else:
		policeman -= 1
print(crime)


n = int(input())
a = list(map(int, input().split()))
free = 0
ans = 0
for i in a:
	if i > 0:
		free += i
	elif free + i >= 0:
		free -= 1
	else:
		ans += 1
print(ans)


n = int(input())
x = [int(x) for x in input().split()]
unt = 0
off = 0
for i in x:
	if i == -1 and off == 0:
		unt = unt + 1
	elif i == -1 and off != 0:
		off = off - 1
	else:
		off = off + i
print(unt)


__author__ = 'runekri3'
n = int(input())
events = list(map(int, input().split()))
officers = 0
untreated_crimes = 0
for event in events:
	if event == -1:
		if officers == 0:
			untreated_crimes += 1
		else:
			officers -= 1
	else:
		officers += event
print(untreated_crimes)


n = int(input())
arr = [int(x) for x in input().split()]
police = 0
ans = 0
for x in arr:
	if x != -1:
		police += x
	elif x == -1:
		if police == 0:
			ans += 1
		else:
			police -= 1
print(ans)


s = int(input())
x = input().split()
crime = 0
officer = 0
for i in x:
	if i == '-1':
		if officer > 0:
			officer -= 1
		else:
			crime += 1
	else:
		officer += int(i)
print(crime)


input()
(*l,) = map(int, input().split())
a = s = 0
for i in l:
	s += i
	if s < 0:
		a += 1
		s = 0
print(a)


n = int(input())
events = list(map(int, input().split(' ')))
forces = 0
untreat = 0
for event in events:
	forces += event
	if forces == -1:
		untreat += 1
		forces = 0
print(untreat)


n = int(input())
A = list(map(int, input().split()))
p = s = 0
for a in A:
	if a < 0 and p == 0:
		s += 1
	elif a < 0 and p > 0:
		p -= 1
	else:
		p += a
print(s)


def main():
	cops = 0
	crimes = 0
	size = int(input())
	x = [int(i) for i in input().split()]
	for i in range(size):
		if x[i] > 0:
			cops += x[i]
		elif x[i] < 0:
			if cops == 0:
				crimes += 1
			else:
				cops -= 1
	print(crimes)
main()


n = int(input())
a = [int(x) for x in input().strip().split()]
c = 0
p = 0
for i in range(len(a)):
	if a[i] == -1:
		if p == 0:
			c += 1
		else:
			p = p + a[i]
	elif a[i] != -1:
		p += a[i]
print(c)


n = int(input())
x = list(map(int, input().split()))
availableOfficers = 0
ans = 0
for i in range(n):
	if x[i] > 0:
		availableOfficers += x[i]
	elif availableOfficers > 0:
		availableOfficers -= 1
	else:
		ans += 1
print(ans)


n = int(input())
b = list(map(int, input().split()))
cnt = sum = 0
for i in range(len(b)):
	if sum + b[i] < 0:
		cnt = cnt + 1
	else:
		sum += b[i]
print(cnt)


n = int(input())
arr = map(int, input().split())
s = 0
cri = 0
for i in arr:
	if i == -1:
		if s > 0:
			s -= 1
		else:
			cri += 1
	else:
		s += i
print(cri)


import functools
n = int(input())
s = input()
l = s.split(' ')
map(int(), l)
count = 0
sum = 0
for i in range(n):
	sum = sum + int(l[i])
	if sum < 0:
		count = count + 1
		sum = 0
print(count)


event = int(input())
list1 = [int(v) for v in input().split()]
police = 0
ans = 0
for i in range(event):
	if list1[i] > 0:
		police += list1[i]
	elif police == 0:
		ans += 1
	else:
		police += list1[i]
print(ans)


k = int(input())
l = list(map(int, input().split()))
ct = 0
r = 0
for i in l:
	if i < 0:
		if r > 0:
			r = r - 1
		else:
			ct = ct + 1
	else:
		r = r + i
print(ct)


input()
eventsL = list(map(int, input().split()))
availPol = 0
res = 0
for value in eventsL:
	availPol += value
	if availPol < 0:
		res += 1
		availPol = 0
print(res)


n = int(input())
x = input().split()
for i in range(n):
	x[i] = int(x[i])
c = 0
d = 0
for j in range(n):
	if x[j] > 0:
		c += x[j]
	elif x[j] == -1 and c > 0:
		c -= 1
	elif x[j] == -1 and c <= 0:
		d += 1
print(d)


n = int(input())
eve = list(map(int, input().split()))
c = 0
cnt = 0
for i in eve:
	c += i
	if c < 0:
		cnt += 1
		c = 0
print(cnt)


n = int(input())
a = list(map(int, input().split()))[:n]
recruits = []
crimes = 0
for i in a:
	if i == -1 and 1 not in recruits:
		crimes += 1
	elif i == -1 and 1 in recruits:
		recruits.remove(1)
	elif i != -1:
		for i in range(1, i + 1):
			recruits.append(1)
print(crimes)


n = int(input())
a = [int(i) for i in input().split()]
s = 0
c = 0
for i in a:
	if i == -1 and s == 0:
		c += 1
	elif i > 0:
		s += i
	else:
		s -= 1
print(c)


n = int(input())
l = list(map(int, input().rstrip().split()))
sum = 0
c = 0
for i in range(0, len(l)):
	if l[i] > 0:
		sum += l[i]
	elif sum > 0:
		sum -= 1
	else:
		c += 1
print(c)


def solve(length, n):
	x = 0
	ans = 0
	for i in range(length):
		x = x + n[i]
		if x < 0:
			ans = ans + 1
			x = 0
	return ans
user = int(input())
a = input()
l = []
l = a.split()
for i in range(user):
	l[i] = int(l[i])
print(solve(user, l))


b = int(input())
c = 0
d = 0
a = [int(i) for i in input().split()]
for i in range(1, b + 1):
	if a[i - 1] < 0 and d <= 0:
		c += 1
	elif a[-1] < 0 and d > 0:
		d += a[i - 1]
	else:
		d += a[i - 1]
print(c)


int(input())
List = list(map(int, input().split()))
Officers = 0
Crimes = 0
for i in List:
	if i > 0:
		Officers += i
	elif Officers > 0:
		Officers -= 1
	else:
		Crimes += 1
print(Crimes)


number_of_events = int(input())
events = [int(i) for i in input().split()]
number_of_policemen = 0
number_of_cases = 0
output = 0
for i in events:
	if i > 0:
		number_of_policemen += i
	elif i < 0:
		if number_of_policemen > 0:
			number_of_policemen -= 1
		elif number_of_policemen == 0:
			output += 1
print(output)


n = int(input())
ns = map(int, input().split())
(crime, hire) = (0, 0)
for i in ns:
	if i == -1:
		if hire == 0:
			crime += 1
		else:
			hire -= 1
	else:
		hire += i
print(crime)


n = int(input())
event = [int(event) for event in input().split()]
cop = 0
res = 0
for i in range(n):
	if event[i] >= 0:
		cop += event[i]
	if event[i] < 0:
		tmp = cop + event[i]
		if tmp >= 0:
			cop = tmp
		else:
			res += tmp
			cop = 0
print(res * -1)


input()
events = list(map(int, input().split()))
polices = 0
passed = 0
for e in events:
	if e < 0 and polices > 0:
		polices -= 1
	elif e < 0 and polices == 0:
		passed += 1
	elif e > 0:
		polices += e
print(passed)


input()
n = map(int, input().split())
crimes = 0
officers = 0
for i in n:
	if i == -1 and officers <= 0:
		crimes += 1
	elif i == -1 and officers > 0:
		officers -= 1
	elif i > 0:
		officers += i
print(crimes)


n = int(input())
l = [int(x) for x in input().split()]
s = 0
c = 0
count = 0
for i in range(n):
	x = l[i]
	if l[i] > 0:
		s = s + x
	elif s != 0:
		c = s + x
		s = s - 1
	else:
		count = count + 1
print(count)


n = int(input())
cops = 0
answer = 0
lst = list(map(int, input().split()))
for i in lst:
	if i == -1:
		if cops < 1:
			answer += 1
		else:
			cops -= 1
	else:
		cops += i
print(answer)


n = int(input())
x = [int(x) for x in input().split()]
a = cnt = 0
for i in x:
	if i == -1:
		a = a - 1
	else:
		a = a + i
	if a < 0:
		cnt = cnt + 1
		a = 0
print(cnt)


n = int(input())
cases = [int(i) for i in input().split()]
policemans = 0
crimes = 0
for case in cases:
	if case < 0:
		if policemans > 0:
			policemans -= 1
		else:
			crimes += 1
	else:
		policemans += case
print(crimes)


n = int(input())
l = list(map(int, input().rstrip().split()))
count = 0
c = 0
for i in l:
	if i > 0:
		c += i
	else:
		c -= 1
	if c < 0:
		count += 1
		c = 0
print(count)


n = int(input())
a = list(map(int, input().strip().split(' ')))
police = 0
crime = 0
untreted = 0
for i in a:
	if i == -1:
		crime -= 1
	else:
		crime += i
	if crime < 0:
		untreted += -crime
		crime = 0
print(untreted)


import sys
f = sys.stdin
n = int(f.readline())
s = f.readline().split()
total = 0
r = 0
for j in s:
	d = int(j)
	if d < 0:
		if total == 0:
			r += 1
		else:
			total -= 1
	else:
		total += d
print(str(r))


t = int(input())
n = list(map(int, input().split()))
p = 0
ans = 0
for i in n:
	if i > 0:
		p += i
	else:
		x = p + i
		if x < 0:
			ans += abs(x)
		else:
			p += i
print(ans)


n = int(input())
events = list(map(int, input().split(' ')))
untreated_event = 0
officer_available = 0
for i in events:
	if i == -1 and officer_available > 0:
		officer_available -= 1
	elif i == -1 and officer_available == 0:
		untreated_event += 1
	else:
		officer_available += i
print(untreated_event)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
sys.setrecursionlimit(100000000)
ii = lambda : int(input())
si = lambda : input()
jn = lambda x, l: x.join(map(str, l))
sl = lambda : list(map(str, input().strip()))
mi = lambda : map(int, input().split())
mif = lambda : map(float, input().split())
lii = lambda : list(map(int, input().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
mod = 1000000007
n = ii()
arr = lii()
p = 0
count = 0
for ele in arr:
	if ele == -1:
		if p == 0:
			count += 1
		else:
			p -= 1
	else:
		p += ele
print(count)


n = int(input())
events = list(map(int, input().split()))
cnt = 0
balance = 0
for e in events:
	if e > 0:
		balance += e
	elif balance > 0:
		balance -= 1
	else:
		cnt += 1
print(cnt)


n = input()
(count, res) = (0, 0)
for i in list(map(int, input().split())):
	if i > 0 and res < 0:
		res = 0
	res += i
	if i < 0 and res < 0:
		count += 1
print(count)


n = int(input())
a = list(map(int, input().split()))
r = 0
u = 0
for i in a:
	if i != -1:
		r = r + i
	elif r > 0:
		r = r - 1
	else:
		u = u + 1
print(u)


n = int(input())
crimes = list(map(int, input().split()))
u = 0
o = 0
for c in crimes:
	if c == -1:
		if o >= 1:
			o -= 1
		else:
			u += 1
	else:
		o += c
print(u)


n = int(input())
mas = [int(i) for i in input().split()]
pcount = 0
scount = 0
for i in range(len(mas)):
	if mas[i] == -1 and pcount == 0:
		scount += 1
	elif mas[i] == -1 and pcount > 0:
		pcount -= 1
	else:
		pcount += mas[i]
print(scount)


n = int(input())
l = list(map(int, input().split()))
x = 0
cnt = 0
for i in l:
	if i == -1:
		if x == 0:
			cnt += 1
		else:
			x -= 1
	elif i != -1:
		x += i
print(cnt)


n = int(input())
events = tuple(map(int, input().split()))
(solution, police) = (0, 0)
for i in events:
	if police == 0 and i == -1:
		solution += 1
	elif police > 0 and i == -1:
		police -= 1
	else:
		police += i
print(solution)


import sys
from functools import reduce
from collections import Counter
import time
import datetime
import math

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

def sip():
	return sys.stdin.readline()

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

def mips():
	return map(str, sys.stdin.readline().split())

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

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.insert(i, arr)
	return lst

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

def minJumps(arr, n):
	jumps = [0 for i in range(n)]
	if n == 0 or arr[0] == 0:
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if i <= j + arr[j] and jumps[j] != float('inf'):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n - 1]

def dic(arr):
	return Counter(arr)

def check_prime(n):
	if n < 2:
		return False
	for i in range(2, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True
n = ip()
arr = lip()
count = 0
val = 0
for i in range(n):
	if arr[i] < 0 and val <= 0:
		count += 1
	elif val > 0 and arr[i] < 0:
		val += arr[i]
	else:
		val += arr[i]
print(count)


n = int(input())
l = list(map(int, input().split()))
cnt = 0
p_cnt = 0
for i in l:
	if i == -1:
		if p_cnt > 0:
			p_cnt -= 1
		else:
			cnt += 1
	else:
		p_cnt += i
print(cnt)


def solve(a):
	crimes = 0
	police = 0
	for i in range(len(a)):
		if a[i] > 0:
			police += a[i]
		if a[i] < 0 and police <= 0:
			crimes += 1
		if a[i] < 0 < police:
			police -= 1
			crimes += 0
	return crimes
n = int(input())
array = list(map(int, input().split()))
print(solve(array))


input()
sit = [int(i) for i in input().split()]
(crime, police) = (0, 0)
for i in range(len(sit)):
	if sit[i] == -1:
		if police == 0:
			crime += 1
		else:
			police -= 1
	else:
		police += sit[i]
print(crime)


a = int(input())
c = 0
u = 0
b = list(input().split())
for i in b:
	if i != '-1':
		c = c + int(i)
	elif c > 0:
		c = c - 1
	else:
		u += 1
print(u)


input()
s = list(map(int, input().split()))
untreated = 0
officers = 0
for i in s:
	if i > 0:
		officers += i
	elif i == -1:
		if officers > 0:
			officers -= 1
		else:
			untreated += 1
print(untreated)


Police = 0
Crimes = 0
input()
l = list(map(int, input().split()))
for i in l:
	if i == -1:
		if Police == 0:
			Crimes += 1
		else:
			Police -= 1
	else:
		Police += i
print(Crimes)


n = int(input())
l = list(map(int, input().split()))
ll = []
ans = 0
for i in range(n):
	ans += l[i]
	ll.append(ans)
if min(ll) > 0:
	print(0)
else:
	print(abs(min(ll)))


n = int(input())
l = list(map(int, input().split()))
s = 0
nb = 0
for i in l:
	if s + i < 0:
		nb = nb + 1
	else:
		s = s + i
print(nb)


n = int(input())
x = [int(x) for x in input().split()]
a = 0
ans = 0
for num in x:
	a += num
	if a < 0:
		a = 0
		ans += 1
print(ans)


n = int(input())
e = [int(x) for x in input().split()]
e_c = e[:]
x = 0
for i in range(len(e)):
	if e[i] > 0:
		x += e[i]
		e_c.pop()
	elif e[i] < 0:
		if x >= 1:
			x -= 1
			e_c.pop()
print(len(e_c))


n = int(input())
l = list(map(int, input().split()))
p = 0
answer = 0
for e in l:
	if e == -1:
		if p == 0:
			answer += 1
		else:
			p -= 1
	else:
		p += e
print(answer)


n = int(input())
p = list(map(int, input().split()))
n = 0
s = 0
for item in p:
	if item == -1:
		if n > 0:
			n -= 1
		else:
			s += 1
	else:
		n += item
print(s)


n = int(input())
values = [int(i) for i in input().split()]
c = 0
o = 0
for i in range(0, n):
	if values[i] < 0:
		if not o >= 1:
			c += 1
		else:
			o -= 1
	else:
		o += values[i]
print(c)


n = int(input())
l = list(map(int, input().split()))
c = 0
c1 = 0
ut = 0
for i in range(n):
	if l[i] == -1:
		if c1 == 0:
			ut = ut + 1
		else:
			c1 = c1 - 1
	else:
		c1 = c1 + l[i]
print(ut)


n = int(input())
a = list(map(int, input().split()))
(s, r) = (0, 0)
for x in a:
	if x > 0:
		s += x
	elif s > 0:
		s -= 1
	else:
		r += 1
print(r)


T = int(input())
L = list(map(int, input().split()))
S = 0
K = 0
for I in range(T):
	S += L[I]
	if L[I] == -1 and S < 0:
		S = 0
		K += 1
print(K)


import sys

def main():
	n = int(input())
	a = list(map(int, input().split()))
	i = _sum = 0
	while i < n:
		if a[i] > 0:
			_sum += a[i]
			i += 1
			while i < n and a[i] > 0:
				_sum += a[i]
				i += 1
			while i < n and _sum > 0 and (a[i] < 0):
				a[i] = 0
				_sum -= 1
				i += 1
		else:
			i += 1
	print(a.count(-1))
	return
sys.exit(main())


n = int(input())
nums = [int(x) for x in input().split()]
pcount = 0
ccount = 0
for i in nums:
	if i > 0:
		pcount += i
	elif i == -1:
		if pcount > 0:
			pcount -= 1
		else:
			ccount += 1
print(ccount)


n = int(input())
k = 0
c = 0
p = list(map(int, input().split()))
for i in range(n):
	if p[i] < 0:
		if c != 0:
			c -= 1
		else:
			k += 1
	else:
		c += p[i]
print(k)


n = int(input())
a = map(int, input().split())
police = 0
unattened = 0
for i in a:
	if i == -1:
		if police == 0:
			unattened += 1
		else:
			police -= 1
	else:
		police += i
print(unattened)


n = int(input())
events = list(map(int, input().split()))
hires = 0
untreated = 0
for i in range(n):
	if events[i] == -1:
		if hires == 0:
			untreated += 1
		else:
			hires -= 1
	else:
		hires += events[i]
print(untreated)


n = int(input())
a = input().split()
i = 0
while i < len(a):
	a[i] = int(a[i])
	i = i + 1
i = 0
l = 0
all = 0
while i < len(a):
	if a[i] > 0:
		l += a[i]
	if a[i] < 0:
		if l > 0:
			l -= 1
		else:
			all += 1
	i = i + 1
print(all)


n = int(input())
k = r = 0
for a in map(int, input().split()):
	if a < 0:
		r += k == 0
	k = max(k + a, 0)
print(r)


n = int(input())
action = list(map(int, input().split()))
crime = 0
free_rec = 0
for i in action:
	if i == -1 and free_rec == 0:
		crime += 1
	else:
		free_rec += i
print(crime)


var = int(input())
var_list = input().split()
var_list = [int(i) for i in var_list]
police_len = 0
kill_len = 0
for i in var_list:
	if i != -1:
		police_len += i
	elif police_len == 0:
		kill_len += 1
	else:
		police_len -= 1
print(kill_len)


N = int(input())
L = list(map(int, input().split()))
ans = 0
police = 0
for l in L:
	if l == -1:
		if police == 0:
			ans += 1
		else:
			police -= 1
	else:
		police += l
print(ans)


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


n = int(input())
ppl = [int(s) for s in input().split()]
police = 0
untreated = 0
for i in range(n):
	if ppl[i] > 0:
		police += ppl[i]
	elif police == 0:
		untreated += 1
	else:
		police -= 1
print(untreated)


n = int(input())
seq = list(map(int, input().split()))
police_num = 0
untreated_num = 0
for num in seq:
	if num > -1:
		police_num += num
	elif police_num == 0:
		untreated_num += 1
	else:
		police_num -= 1
print(untreated_num)


t = int(input())
x = list(map(int, input().split()))
crime_counter = 0
police_counter = 0
for i in range(t):
	if x[i] > 0:
		police_counter += x[i]
	elif police_counter > 0:
		police_counter += x[i]
	else:
		crime_counter -= x[i]
print(crime_counter)


n = int(input())
arr = [int(i) for i in input().split()]
count = 0
free = 0
for i in range(n):
	if arr[i] > 0:
		free += arr[i]
	elif free > 0:
		free -= 1
	else:
		count += 1
print(count)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
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 [int(x) for x in sys.stdin.readline().split()]

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

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

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

def S():
	return input()

def main():
	n = I()
	l = LI()
	q = queue.Queue()
	c = 0
	for x in l:
		if x == -1:
			if q.empty():
				c += 1
			else:
				q.get()
		else:
			for i in range(x):
				q.put(1)
	return c
print(main())


n = int(input())
arr = list(map(int, input().split()))
(police, ans) = (0, 0)
for i in arr:
	if i == -1 and police == 0:
		ans += 1
	elif i == -1 and police > 0:
		police -= 1
	elif i > 0:
		if i > 10:
			police += 10
		else:
			police += i
print(ans)


n = input()
crime = 0
sum = 0
a = list(map(int, input().split()))
for i in range(len(a)):
	if a[i] > 0:
		sum += a[i]
	elif a[i] < 0 and sum <= 0:
		crime += a[i]
	else:
		sum += a[i]
print(abs(crime))


input()
c = 0
ans = 0
for i in map(int, input().split()):
	if i == -1:
		if c == 0:
			ans += 1
		else:
			c -= 1
	else:
		c += i
print(ans)


negative_count = 0
input()
numbers = [int(x) for x in input().split()]
current_status = 0
for number in numbers:
	if number > 0:
		current_status += number
	else:
		current_status -= -number
		if current_status < 0:
			negative_count += 1
			current_status = 0
print(negative_count)


n = int(input())
lst = input().split()
for i in range(n):
	lst[i] = int(lst[i])
count = 0
i = 0
pl = 0
while i < n:
	if lst[i] < 0:
		if pl == 0:
			count = count + 1
		else:
			pl = pl - 1
	else:
		pl = pl + lst[i]
	i = i + 1
print(count)


input()
pol = 0
bul = 0
for i in list(map(int, input().split())):
	if i > 0:
		pol += i
	elif pol == 0:
		bul += 1
	elif pol > 0:
		pol -= 1
print(bul)


n = int(input())
s = input().split()
pol = 0
pr = 0
for i in s:
	if int(i) < 0:
		if pol > 0:
			pol = pol - 1
		else:
			pr = pr + 1
	if int(i) > 0:
		pol = pol + int(i)
print(pr)


from typing import List, Tuple

def parse_input() -> Tuple[int, List[int]]:
	return (input().split(), [int(x) for x in input().split()])

def solve(n: int, cs: List[int]) -> int:
	crimes = 0
	officers = 0
	for elem in cs:
		if elem > 0:
			officers += elem
		elif elem == -1 and officers >= 1:
			officers -= 1
		else:
			crimes += 1
	return crimes
(n, cs) = parse_input()
print(solve(n, cs))


n = int(input())
a = list(map(int, input().split()))
p = 0
m = 0
for i in a:
	if i > 0:
		m += i
	elif m > 0 and i < 0:
		m -= 1
	else:
		p += 1
print(p)


n = int(input())
s = input()
r1 = s.split(' ')
police = 0
crime = 0
a = []
for i in range(len(r1)):
	temp = int(r1[i])
	a.append(temp)
for i in range(len(a)):
	if police == 0:
		if a[i] < 0:
			crime = crime + 1
		elif a[i] > 0:
			police = police + a[i]
	elif police != 0:
		if a[i] < 0:
			police = police - 1
		elif a[i] > 0:
			police = police + a[i]
print(crime)


cur = 0
c = 0
n = int(input())
for i in input().split():
	if int(i) > 0:
		cur += int(i)
	elif cur - 1 < 0:
		c += 1
	else:
		cur -= 1
print(c)


n = int(input())
a = list(map(int, input().split()))
c = 0
o = 0
for i in range(len(a)):
	if a[i] < 0:
		if not o >= 1:
			c += 1
		else:
			o -= 1
	else:
		o += a[i]
print(c)


n = int(input())
a = map(int, input().split())
prest = 0
Pol = 0
for i in a:
	if i > 0:
		Pol += i
	elif i < 0 and Pol > 0:
		prest = prest
		Pol = Pol - 1
	elif i < 0 and Pol == 0:
		prest += i
print(abs(prest))


a = int(input())
b = list(map(int, input().split()))
police = 0
untreated = 0
for i in b:
	police += i
	if police < 0:
		untreated += 1
		police = 0
print(untreated)


n = int(input())
line = [int(i) for i in input().split()]
num = 0
po = 0
for i in line:
	if i > 0:
		po += i
	elif po + i >= 0:
		po += i
	else:
		num += 1
print(num)


(n, p, d) = (int(input()), 0, 0)
for i in (int(x) for x in input().split()):
	p += i
	if p == -1:
		p = 0
		d += 1
print(d)


count = 0
n = 0
x = int(input())
y = input().split()
for i in range(x):
	if int(y[i]) < 0:
		if n == 0:
			count += 1
		if n > 0:
			n -= 1
	elif int(y[i]) > 0:
		n = n + int(y[i])
print(count)


current_officers = 0
crimes_free = 0
a = input()
a = [int(i) for i in input().split()]
for i in a:
	if i > 0:
		current_officers += i
	elif current_officers + i >= 0:
		current_officers += i
	else:
		crimes_free -= current_officers + i
		current_officers = 0
print(crimes_free)


n = int(input())
event = list(map(int, input().split()))
cops = 0
answ = 0
for i in event:
	if i == -1:
		if cops == 0:
			answ += 1
		else:
			cops -= 1
	else:
		cops += i
print(answ)


n = int(input())
arr = list(map(int, input().split()))
off = 0
cri = 0
pos = 0
for i in range(len(arr)):
	if arr[i] == -1:
		cri += 1
	else:
		pos = i
		break
if cri != len(arr):
	for j in range(pos, len(arr)):
		if arr[j] != -1:
			off += arr[j]
		elif arr[j] == -1:
			if off > 0:
				off = off - 1
			else:
				cri += 1
print(cri)


def solve(x):
	suc = 0
	polis = 0
	for i in x:
		if i == -1:
			if polis > 0:
				polis -= 1
			else:
				suc += 1
		else:
			polis += i
	return suc
n = int(input())
x = map(int, input().split(' '))
print(solve(x))


n = int(input())
arr = list(map(int, input().split()))
ans = 0
pol = 0
for i in range(n):
	if arr[i] > 0:
		pol += arr[i]
	elif pol == 0:
		ans += 1
	else:
		pol -= 1
print(ans)


def s():
	n = int(input())
	arr = [int(x) for x in input().split(' ')]
	ans = 0
	temp = 0
	for x in arr:
		if temp <= 0 and x == -1:
			ans += 1
		else:
			temp += x
	print(ans)
s()


n = int(input())
a = [int(i) for i in input().split()]
cur = 0
ans = 0
for i in a:
	if i == -1 and cur == 0:
		ans += 1
	if i == -1 and cur != 0:
		cur -= 1
	if i != -1:
		cur += i
print(ans)


events_num = int(input(''))
events = input('').split(' ')
available = 0
untreated = 0
for event in events:
	if int(event) == -1 and available == 0:
		untreated += 1
	elif int(event) == -1 and available != 0:
		available -= 1
	else:
		available += int(event)
print(untreated)


arg = int(input())
for a in range(0, 1):
	l1 = list(map(int, input().strip().split()))
recruits = 0
crimes = 0
for a in l1:
	if a > -1:
		recruits += a
	elif recruits <= 0:
		crimes += 1
	else:
		recruits -= 1
print(crimes)


n = int(input())
a = list(map(int, input().split()))
cop = [0]
crim = []
for i in range(len(a)):
	if a[i] == -1 and cop[0] == 0:
		crim.append(a[i])
	elif a[i] == -1 and cop[0] > 0:
		cop[0] += a[i]
	else:
		cop[0] += a[i]
print(len(crim))


n = int(input())
ls = list(map(int, input().split()))
o = 0
res = 0
for i in ls:
	if i > -1:
		o = o + i
	elif i == -1:
		if o > 0:
			o = o - 1
		else:
			res = res + 1
print(res)


n = int(input())
actions = input().split(' ')
villians = 0
cops = 0
for action in actions:
	if '-' in action:
		if cops > 0:
			cops -= 1
		else:
			villians += 1
	else:
		cops += int(action)
print(villians)


n = int(input())
x = list(map(int, input().split()))
b = 0
for i in range(len(x) - 1, -1, -1):
	if x[i] < 0:
		b += 1
	elif x[i] > 0 and b > 0:
		b -= x[i]
		if b < 0:
			b = 0
print(b)


n = int(input())
events = list(map(int, input().split()))
polices = 0
untreated = 0
for i in events:
	if i < 0:
		if polices > 0:
			polices -= 1
		else:
			untreated += 1
	else:
		polices += i
print(untreated)


n = int(input())
s = list(map(int, input().split()))
crime = police = 0
for i in s:
	if i == abs(i):
		police += i
	elif police == 0:
		crime += 1
	else:
		police -= 1
print(crime)


f = int(input())
a = [int(i) for i in input().split()]
z = x = 0
for i in a:
	if i > 0:
		x += i
	elif x == 0:
		z += 1
	else:
		x -= 1
print(z)


input()
crs = list(map(int, input().split()))
police = 0
unt = 0
for i in range(len(crs)):
	if crs[i] != -1:
		police += crs[i]
	elif police:
		police -= 1
	else:
		unt += 1
print(unt)


n = int(input())
arr = [int(x) for x in input().split(' ')]
recruits = crimes = 0
for i in arr:
	if i == -1:
		if recruits == 0:
			crimes += 1
		else:
			recruits -= 1
	else:
		recruits += i
print(crimes)


t = int(input())
(a, x) = (list(map(int, input().split())), 0)
r = 0
for i in range(len(a)):
	if a[i] > 0:
		r += a[i]
	elif r > 0:
		r -= 1
	else:
		x -= 1
print(abs(x))


n = int(input())
list1 = list(map(int, input().split()))
count = 0
num_rec = 0
for m in range(n):
	if list1[m] == -1:
		if num_rec > 0:
			num_rec -= 1
		else:
			count += 1
	else:
		num_rec += list1[m]
print(count)


n = int(input())
li = list(map(int, input().split()))
count = 0
di = {1: 0}
for i in li:
	if i == -1 and di[1] == 0:
		count += 1
	elif i > 0:
		di[1] = di.get(1, 0) + i
	elif i == -1 and di[1] > 0:
		di[1] = di[1] - 1
print(count)


a = int(input())
b = list(map(int, input().split()))
s = 0
p = 0
for i in b:
	s += i
	if i < 0 and s < 0:
		p += 1
		s = 0
print(p)


crimes = 0
policeCount = 0
n = int(input())
crime = list(map(int, input().split(' ')))
for i in range(n):
	if crime[i] == -1:
		if policeCount == 0:
			crimes += 1
		else:
			policeCount -= 1
	else:
		policeCount += crime[i]
print(crimes)


n = int(input())
investigations = input().split()
deal = 0
lost_deal = 0
for i in range(n):
	deal += int(investigations[i])
	if deal < 0:
		lost_deal += 1
		deal = 0
print(lost_deal)


n = int(input())
events = [int(i) for i in input().split(' ')]
policemen = 0
crimes = 0
for e in events:
	if e < 0:
		if policemen > 0:
			policemen -= 1
		else:
			crimes += 1
	else:
		policemen += e
print(str(crimes))


n = int(input())
a = [int(s) for s in input().split()]
k1 = 0
k = 0
for i in range(n):
	if a[i] == -1 and k1 <= 0:
		k += 1
	elif k1 > 0 and a[i] == -1:
		k1 -= 1
	else:
		k1 += a[i]
print(k)


n = int(input())
evenement = [int(x) for x in input().split()]
police_available = 0
nb_crimes = 0
for x in range(n):
	if evenement[x] >= 1:
		police_available += evenement[x]
	elif evenement[x] == -1:
		if police_available > 0:
			police_available -= 1
		else:
			nb_crimes += 1
print(nb_crimes)


x = int(input())
a = list(map(int, input().split()))
k = 0
s = 0
l = 0
if a[0] == -1:
	l = 1
elif a[0] > 0:
	l = 0
	s = a[0]
for i in range(1, x):
	if a[i] > 0:
		s = s + a[i]
	if a[i] == -1:
		k = k + 1
	if k > s:
		l = l + k - s
		k = 0
		s = 0
print(l)


p = result = 0
input()
for i in [int(i) for i in input().split()]:
	if i > 0:
		p += i
	else:
		if not p:
			result += 1
		p = max(0, p - 1)
print(result)


s = int(input())
l = input().split()
crimes = 0
police = 0
for i in map(int, l):
	if i > 0 or police > 0:
		police += i
	else:
		crimes += 1
print(crimes)


n = int(input())
s = list(map(int, input().split()))
crimes = 0
officers = 0
for i in range(len(s)):
	if s[i] == -1:
		if officers > 0:
			officers -= 1
		else:
			crimes += 1
	elif s[i] > 0:
		officers += s[i]
print(crimes)


input()
cops = 0
count = 0
for e in map(int, str.split(input())):
	if e == -1:
		if cops == 0:
			count += 1
		cops = max(0, cops - 1)
	else:
		cops += e
print(count)


n = int(input())
Array = [i for i in map(int, input().split())]
(j, m) = (0, 0)
l = 0
while j < n:
	m += Array[j]
	if m < 0:
		l -= m
		m = 0
	j += 1
print(l)


n = int(input())
(Sum, count) = (0, 0)
for x in map(int, input().split()):
	Sum += x
	if x > 0:
		Sum = max(Sum, x)
	if x < 0 and Sum < 0:
		count += 1
print(count)


n = int(input())
arr = list(map(int, input().split()))
ut = 0
avail = 0
for i in range(n):
	if arr[i] < 0 and avail == 0:
		ut += 1
	elif arr[i] < 0 and avail > 0:
		avail -= 1
	else:
		avail += arr[i]
print(ut)


n = int(input())
A = input().split()
c = 0
p = 0
for i in range(n):
	if int(A[i]) > 0:
		p += int(A[i])
	elif p > 0:
		p -= 1
	else:
		c += 1
print(c)


input()
t = 0
res = 0
for i in map(int, input().split()):
	if i == -1:
		if t == 0:
			res = res + 1
		else:
			t = t - 1
	else:
		t += i
print(res)


numofevents = int(input())
crimeoccurrence = list(map(int, input().split()))
untreatedcrime = 0
currentpolice = 0
for occurrence in crimeoccurrence:
	if occurrence == -1:
		if currentpolice == 0:
			untreatedcrime += 1
		else:
			currentpolice -= 1
	else:
		currentpolice += occurrence
print(untreatedcrime)


events = int(input())
crimes = []
crimes = list(map(int, input().split(' ')))
untreated = 0
policemen = 0
for crime in crimes:
	if crime == -1:
		if policemen > 0:
			policemen -= 1
		else:
			untreated += 1
	if crime > 0:
		policemen += crime
print(untreated)


n = input()
a = input().split()
p = 0
u = 0
for i in range(0, len(a)):
	if p == 0 and a[i] == '-1':
		u = u + 1
	elif p > 0 and a[i] == '-1':
		p = p - 1
	else:
		p = p + int(a[i])
print(u)


n = int(input())
l = list(map(int, input().split()))
(d, a) = (0, 0)
for i in range(n):
	if l[i] == -1 and d > 0:
		d -= 1
	elif l[i] == -1 and d == 0:
		a += 1
	else:
		d += l[i]
print(a)


n = int(input())
u = [int(i) for i in input().split()]
o = 0
res = 0
for i in u:
	if i == -1 and o == 0:
		res += 1
	elif i == -1 and o >= 1:
		o -= 1
	elif i >= 1:
		o += i
print(res)


n = int(input())
chronology = list(map(int, input().split()))
cop_count = 0
unsolved_crimes = 0
for i in chronology:
	cop_count += i
	if cop_count < 0:
		unsolved_crimes += 1
		cop_count = 0
print(unsolved_crimes)


n = int(input())
s = list(map(int, input().split()))
sm = 0
for i in s[::-1]:
	sm = min(0, sm + i)
print(-sm)


n = int(input())
rec = 0
cnt = 0
crimes = list(map(int, input().split()))
for i in crimes:
	if i == -1:
		if rec > 0:
			rec -= 1
		else:
			cnt += 1
	else:
		rec += i
print(cnt)


n = int(input())
L = input().split()
L = [int(i) for i in L]
crime = 0
temp = 0
for i in range(n):
	if temp != 0:
		if L[i] == -1:
			temp -= 1
		else:
			temp += L[i]
	elif L[i] == -1:
		crime += 1
	else:
		temp = L[i]
print(crime)


def solve(events):
	untreatedCrimes = 0
	policeAvailable = 0
	for event in events:
		if event == -1:
			if policeAvailable > 0:
				policeAvailable -= 1
			else:
				untreatedCrimes += 1
		else:
			policeAvailable += event
	return untreatedCrimes
n = int(input())
events = input().split(' ')
events = [int(i) for i in events]
print(solve(events))


n = int(input())
arr = input().split()
manp = 0
crm = 0
for item in arr:
	if manp == 0 and int(item) == -1:
		crm += 1
	else:
		manp = manp + int(item)
print(crm)


n = int(input())
events = list(map(int, input().split()))
i = count = police = 0
for i in range(n):
	if events[i] > 0:
		if police > 0:
			police += events[i]
		else:
			police = events[i]
	else:
		police -= 1
	if police < 0:
		count += 1
print(count)


n = int(input())
l = [int(i) for i in input().split()]
sum = 0
extra = 0
for i in l:
	if i == -1:
		if extra == 0:
			sum += 1
		else:
			extra -= 1
	else:
		extra += i
print(sum)


n = int(input())
x = list(map(int, input().split()))
sum = 0
counter = 0
for i in x:
	if i == -1 and sum == 0:
		counter += 1
	elif i != -1:
		sum += i
	else:
		sum -= 1
print(counter)


n = int(input())
L = [int(x) for x in input().split()]
c = p = 0
for i in L:
	if i == -1 and p == 0:
		c += 1
	if i == -1 and p != 0:
		p -= 1
	if i > 0:
		p += i
print(c)


n = input()
data = input()
lst = list()
lst2 = list()
count = 0
for j in data.split():
	lst.append(int(j))
for i in lst:
	count = count + i
	if count < 0:
		lst2.append(i)
		count = 0
l = len(lst2)
print(l)


times = int(input())
events = input().split(' ')
poli = 0
roubos = 0
for i in range(times):
	if int(events[i]) == -1:
		if poli > 0:
			poli = poli - 1
		else:
			roubos = roubos + 1
	else:
		poli = poli + int(events[i])
print(roubos)


(n,) = list(map(int, input().split()))
xs = list(map(int, input().split()))
c = 0
r = 0
for x in xs:
	c += x
	if c < 0:
		r -= c
		c = 0
print(r)


n = int(input())
x = list(map(int, input().split()))
cr = 0
cop = 0
for i in range(n):
	if cop > 0 and x[i] == -1:
		cop -= 1
	elif cop == 0 and x[i] == -1:
		cr += 1
	else:
		cop += x[i]
print(cr)


n = int(input())
a = [int(s) for s in input().split()]
police = 0
crimeTracker = 0
for i in range(n):
	if a[i] > 0:
		police += a[i]
	elif police > 0:
		police -= 1
	else:
		crimeTracker += 1
print(crimeTracker)


input()
p = 0
ans = 0
for x in map(int, input().split()):
	if x == -1:
		if p == 0:
			ans += 1
		else:
			p -= 1
	else:
		p += x
print(ans)


n = int(input())
r = list(map(int, input().split()))
policeman = 0
untreated = 0
for i in r:
	if i == -1:
		if policeman == 0:
			untreated += 1
		else:
			policeman -= 1
	else:
		policeman += i
print(untreated)


n = int(input())
x = [int(i) for i in input().split()]
Sum = 0
count = 0
for i in x:
	Sum += i
	if Sum < 0:
		count += 1
		Sum = 0
print(count)


input()
policemen = 0
crimes = 0
for i in map(int, input().split()):
	if i == -1 and policemen == 0:
		crimes += 1
	elif i == -1 and policemen > 0:
		policemen -= 1
	else:
		policemen += i
print(crimes)


def crime_city(statistic):
	police = 0
	crime = 0
	for value in statistic:
		if value == -1:
			crime += 1
		elif value > 0:
			police += value
		if value == -1 and police > 0:
			crime -= 1
			police -= 1
	return crime
number = int(input())
lst = list(map(int, input().split()))
print(crime_city(lst))


import sys
n = int(input())
l = [int(x) for x in input().split()]
police = 0
crime = 0
for i in l:
	if i >= 0:
		police += i
	elif police > 0:
		police -= 1
	else:
		crime += 1
print(crime)


n = int(input())
a = list(map(int, input().split()))
x = 0
pr = 0
for i in a:
	x = x + i
	if x < 0:
		pr = pr + 1
		x = 0
print(pr)


n = int(input())
acts = [int(x) for x in input().split()]
unn = 0
fre = 0
for i in acts:
	if i > 0:
		fre += i
	elif i == -1:
		if fre > 0:
			fre -= 1
		else:
			unn += 1
print(unn)


_ = input()
events = list(map(int, input().split()))
officers_number = 0
crimes = 0
for event in events:
	if event == -1 and officers_number < 1:
		crimes += 1
	elif event == -1:
		officers_number -= 1
	elif event > 0:
		officers_number += event
print(crimes)


n = int(input())
cases = [int(i) for i in input().split()]
police = 0
res = 0
for e in cases:
	if e != -1:
		police += e
	elif police == 0:
		res += 1
	else:
		police -= 1
print(str(res))


n = int(input())
events = list(map(int, input().split()))
(policemen, untracked) = (0, 0)
for event in events:
	if event == -1 and policemen == 0:
		untracked += 1
	else:
		policemen += event
print(untracked)


import sys
from math import sqrt, floor
inp = sys.stdin.readline
read = lambda : list(map(int, inp().split()))

def solve():
	n = int(inp())
	arr = read()
	(unt, hir) = (0, 0)
	for i in arr:
		if i < 0:
			if hir:
				hir -= 1
			else:
				unt += 1
		else:
			hir += i
	print(unt)
solve()


from sys import stdin, stdout
from math import gcd, sqrt, floor, ceil

def list_inp(x):
	return list(map(x, input().split()))

def map_inp(x):
	return map(x, input().split())

def lcm(a, b):
	return a * b / gcd(a, b)
t = int(input())
arr = list_inp(int)
plman = 0
cc = 0
for i in range(t):
	a = arr[i]
	if a != -1:
		plman += a
	if a == -1 and plman <= 0:
		cc += 1
	elif a == -1 and plman > 0:
		plman -= 1
print(cc)


n = int(input())
m = list(map(int, input().split()))
q = 0
ans = 0
for i in m:
	q += i
	if q < 0:
		ans += 1
		q = 0
print(ans)


f = lambda : map(int, input().split())
f()
s = c = 0
for i in list(f()):
	if i == -1 and s == 0:
		c += 1
	else:
		s += i
print(c)


n = int(input())
c = list(map(int, input().split()))
l = 0
k = 0
for i in range(n):
	if c[i] > 0:
		k += c[i]
	elif k > 0:
		l -= min(0, k + c[i])
		k = max(0, k + c[i])
	else:
		l -= c[i]
print(l)


n = int(input())
events = list(map(int, input().split()))
untreated_Crimes = 0
pol_Available = 0
for event in events:
	if event == -1:
		if pol_Available > 0:
			pol_Available -= 1
		else:
			untreated_Crimes += 1
	else:
		pol_Available += event
print(untreated_Crimes)


a = int(input())
b = list((int(x) for x in input().split()))
crimes = 0
officer = 0
for i in b:
	if i < 0 and officer == 0:
		crimes += 1
	if i > 0:
		officer += i
	elif i < 0 and officer > 0:
		officer -= 1
print(crimes)


n = int(input())
cases = list(map(int, input().split()))
officers = crimes = 0
for i in cases:
	if i > 0:
		officers += i
		continue
	if i < 0 and officers > 0:
		officers -= 1
		continue
	if i < 0:
		crimes += 1
print(crimes)


n = int(input())
arr = [int(x) for x in input().split()]
c = 0
d = 0
for i in arr:
	if i < 0:
		if d == 0:
			c += 1
		else:
			d -= 1
	else:
		d += i
print(c)


n = int(input())
l = list(map(int, input().split()))
m = 0
ans = 0
for i in l:
	if i == -1:
		if m == 0:
			ans += 1
		else:
			m -= 1
	else:
		m += i
print(ans)


n = int(input())
x = [int(t) for t in input().split()]
b = k = 0
for d in x:
	b += d
	if b < 0:
		k += 1
		b = 0
print(k)


k = int(input())
a = list(map(int, input().split()))
(c, d) = (0, 0)
for i in a:
	c += i
	if c < 0:
		c = 0
		d += 1
print(d)


n = int(input())
events = map(int, input().split())
recruits = 0
crimes = 0
for e in events:
	recruits += e
	if recruits < 0:
		recruits = 0
		crimes += 1
print(crimes)


n = int(input())
a = [int(a) for a in input().split()]
count = 0
b = 0
for i in range(n):
	if a[i] == 1:
		b = b + 1
	elif a[i] == 2:
		b = b + 2
	elif a[i] == 3:
		b = b + 3
	elif a[i] == 4:
		b = b + 4
	elif a[i] == 5:
		b = b + 5
	elif a[i] == 6:
		b = b + 6
	elif a[i] == 7:
		b = b + 7
	elif a[i] == 8:
		b = b + 8
	elif a[i] == 9:
		b = b + 9
	elif a[i] == 10:
		b = b + 10
	elif a[i] == 11:
		b = b + 11
	elif a[i] == 12:
		b = b + 12
	else:
		b = b - 1
		if b < 0:
			count += 1
			b = 0
print(count)


n = int(input())
t = list(map(int, input().split()))
rec = 0
uns = 0
for i in range(n):
	if t[i] > 0:
		rec += t[i]
	elif t[i] < 0 and rec != 0:
		rec -= 1
	elif t[i] < 0 and rec == 0:
		uns += t[i]
print(-uns)


n = int(input())
e = [int(x) for x in input().split()]
num_pol = 0
num_cri = 0
for i in range(n):
	if num_pol == 0 and e[i] < 0:
		num_cri += 1
	elif num_pol > 0 and e[i] < 0:
		num_pol -= 1
	elif e[i] > 0:
		num_pol += e[i]
print(num_cri)


(n, event, hired, crime, result) = (int(input()), list(map(int, input().split())), 0, 0, 0)
for i in event:
	if i > 0:
		hired += i
	elif hired > 0:
		hired -= 1
	else:
		result += 1
print(result)


police = 0
crime = 0
nos_event = input()
event = input()
for e in event.split(' '):
	e = int(e)
	if police == 0 and e == -1:
		crime += 1
	else:
		police += e
print(crime)


n = int(input())
x = [int(q) for q in input().split()]
s = 0
ans = 0
for i in range(len(x)):
	if x[i] == -1:
		s -= 1
		if s < 0:
			ans += 1
			s = 0
	else:
		s += x[i]
print(ans)


n = int(input())
s = map(int, input().split())
count = 0
z = 0
for i in s:
	z += i
	if z == -1:
		count += 1
		z = 0
print(count)


x = int(input())
y = input()
y = y.split()
t = []
recruit = 0
crime = 0
for i in y:
	t.append(int(i))
for i in t:
	if i > 0:
		recruit += i
	elif recruit > 0:
		recruit -= 1
	else:
		crime += 1
print(crime)


n = int(input())
l = list(map(int, input().split()))
police = 0
untreated = 0
for item in l:
	if item == -1:
		police -= 1
		if police < 0:
			untreated += 1
			police = 0
	else:
		police = police + item
print(untreated)


n = int(input())
l = list(map(int, input().split()))
sum = 0
count = 0
for item in l:
	if sum > 0:
		sum += item
	elif item != -1:
		sum += item
	else:
		count += 1
print(count)


n = int(input())
s = list(map(int, input().split()))
police_officers = 0
crimes = 0
for i in s:
	if i > 0:
		police_officers = police_officers + i
	if i < 0:
		if police_officers > 0:
			police_officers = police_officers - 1
		else:
			crimes += 1
print(crimes)


n = int(input())
s = k = 0
for i in map(int, input().split()):
	s += i
	if s < 0:
		k += 1
		s = 0
print(k)


a = int(input())
b = list(map(int, input().split()))
po = 0
count = 0
for i in b:
	if po == 0 and i == -1:
		count += 1
	elif po != 0 and i == -1:
		po -= 1
	elif i > 0:
		po += i
print(count)


import os
import sys
from io import BytesIO, IOBase

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	(b, cnt) = (0, 0)
	for i in range(n):
		if b + a[i] < 0:
			cnt += 1
		else:
			b += a[i]
	print(cnt)
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')
solve()


n = int(input())
a = list(map(int, input().split()))
c = 0
d = 0
z = a.count(-1)
for i in range(n):
	if a[i] == -1:
		if d > 0:
			d -= 1
			c += 1
	else:
		d += a[i]
print(z - c)


n = int(input())
s = list(map(int, input().split()))
crime = 0
off = 0
for i in range(n):
	if s[i] == -1:
		if off == 0:
			crime += 1
		else:
			off -= 1
	else:
		off += s[i]
print(crime)


def ans(a):
	s = 0
	x = 0
	for i in a:
		if i == -1:
			if x > 0:
				x -= 1
			else:
				s += 1
		else:
			x += i
	return s
n = int(input())
a = list(map(int, input().split()))
print(ans(a))


hired_policeman = 0
crimes = 0
untreated_crime = 0
events = int(input())
occur = input().split(' ')
occur = [int(occur[i]) for i in range(0, events)]
for count in occur:
	if count == -1 and hired_policeman > 0:
		hired_policeman -= 1
	elif count == -1 and hired_policeman == 0:
		untreated_crime += 1
	else:
		hired_policeman += count
print(untreated_crime)


a = int(input())
b = input().split()
sum = 0
count = 0
for j in b:
	i = int(j)
	if i < 0:
		sum += i
		if sum < 0:
			count += 1
	elif sum < 0:
		sum = i
	else:
		sum += i
print(count)


def main():
	numEvents = int(input())
	events = [None] * 10
	numOfficers = 0
	crimesLeft = 0
	for event in input().split(' '):
		if int(event) < 0:
			if numOfficers > 0:
				numOfficers -= 1
			else:
				crimesLeft += 1
		else:
			numOfficers += int(event)
	print(crimesLeft)
main()


n = int(input())
lst = list((int(num) for num in input().split()))[:n]
count = 0
officers = 0
for i in range(0, n):
	if lst[i] > 0:
		officers += lst[i]
	elif lst[i] < 0 and officers <= 0:
		count = count + 1
	elif lst[i] < 0 and officers >= 0:
		officers = officers - 1
print(count)


n = int(input())
v = list(map(int, input().split()))
acum = [0]
for i in range(n):
	acum.append(acum[i] + v[i])
print(abs(min(acum)))


n = int(input())
arr = input()
l = list(map(int, arr.split(' ')))
crimesUntreated = 0
currentPolice = 0
for i in range(n):
	e = l[i]
	if e == -1:
		if currentPolice <= 0:
			crimesUntreated = crimesUntreated + 1
		else:
			currentPolice = currentPolice - 1
	else:
		currentPolice = currentPolice + l[i]
print(crimesUntreated)


n = int(input())
val = [int(i) for i in input().split()]
res = 0
prev = 0
for i in val:
	if i < 0:
		if prev == 0:
			res += 1
		else:
			prev += i
	else:
		prev += i
print(res)


n = int(input())
N = [int(x) for x in input().split()]
s = 0
z = 0
for i in range(n):
	s += N[i]
	if s < 0:
		z += 1
		s = 0
print(z)


ps = input()
p = ans = 0
l = list(map(int, input().split()))
for i in l[::-1]:
	ans = min(0, ans + i)
print(-ans)


n = int(input())
arr = list(map(int, input().split()))
ans = 0
crimes = 0
for m in arr:
	if m < 0:
		m = abs(m)
		if crimes < m:
			ans += m - crimes
			crimes = 0
		else:
			crimes -= m
	else:
		crimes += m
print(ans)


input_str = int(input())
timeline = list(map(lambda x: int(x), input().split(' ')))
police_available = 0
untreated_crimes = 0
for item in timeline:
	if item > 0:
		police_available += item
	elif police_available != 0:
		police_available += item
	else:
		untreated_crimes += 1
print(untreated_crimes)


n = int(input())
inp = [int(x) for x in input().split()]
crimes = 0
cops = 0
for x in inp:
	if x == -1 and cops == 0:
		crimes += 1
	else:
		cops += x
print(crimes)


n = int(input())
spisok = list(input().split())
prest = 0
pol = 0
for i in spisok:
	if i != '-1':
		pol += int(i)
	elif pol > 0:
		pol -= 1
	elif pol == 0:
		prest += 1
print(prest)


t = int(input())
s = 0
c = 0
l = list(map(int, input().split()))
for i in range(len(l)):
	if s == 0 and l[i] == -1:
		c += 1
	elif l[i] == -1 and s != 0:
		s -= 1
	else:
		s = s + l[i]
print(c)


from sys import stdin

def main():
	stdin.readline()
	cop = crime = 0
	for x in map(int, stdin.readline().strip().split()):
		if x == -1:
			if cop:
				cop -= 1
			else:
				crime += 1
		else:
			cop += x
	return crime
print(main())


n = int(input())
A = list(map(int, input().split()))
numofpolice = 0
untreated = 0
for i in range(n):
	if A[i] != -1:
		numofpolice = numofpolice + A[i]
	elif numofpolice > 0:
		numofpolice = numofpolice - 1
	else:
		untreated = untreated + 1
print(untreated)


n = int(input())
arr = map(int, input().split(' '))
police = 0
crime = 0
for i in arr:
	if i == -1:
		crime += 1
	elif i > 0:
		police += i
	if i == -1 and police > 0:
		crime -= 1
		police -= 1
print(crime)


input()
s = [int(i) for i in input().split()]
p = 0
c = 0
for i in range(len(s)):
	if s[i] == -1:
		if p != 0:
			p = p + s[i]
		else:
			c = c + s[i]
	else:
		p = p + s[i]
print(abs(c))


n = int(input())
k = [int(x) for x in input().split()]
t = 0
occur = 0
for i in range(n):
	if k[i] == -1:
		if t == 0:
			occur += 1
		else:
			t -= 1
	if k[i] != -1:
		t += k[i]
print(occur)


a = int(input())
l = list(map(int, input().split()))
k = 0
sum = 0
for a in l:
	if a >= 1:
		sum += a
	if a == -1:
		sum += a
		if sum < 0:
			sum = 0
			k += 1
print(k)


n = int(input())
p = [int(x) for x in input().split()]
s = 0
ans = 0
for i in range(n):
	if p[i] == -1 and s <= 0:
		ans = ans + 1
	if p[i] == -1 and s > 0:
		s = s - 1
	if p[i] > 0:
		s = s + p[i]
print(ans)


n = int(input())
new = input().split()
list1 = [int(i) for i in new]
police = 0
criminal = 0
occured = 0
for i in list1:
	if i == -1:
		criminal += -1
	else:
		police += i
	if police + criminal < 0:
		occured += 1
		criminal = 0
		police = 0
print(occured)


n = int(input())
event_list = list(map(int, input().split()))
officers_free = 0
untreated = 0
for i in event_list:
	if i == -1:
		if officers_free > 0:
			officers_free -= 1
		else:
			untreated += 1
	else:
		officers_free += i
print(untreated)


t = int(input())
l = list(map(int, input().split()))
v = 0
u = 0
for i in range(t):
	if l[i] > 0:
		v = v + l[i]
	elif v - 1 < 0:
		u = u + 1
	else:
		v = v - 1
print(u)


n = int(input())
events = list(map(int, input().strip().split()))
(police_officer, untreated) = (0, 0)
for event in events:
	if event > 0:
		police_officer += event
	elif event < 0 and police_officer > 0:
		police_officer -= 1
	elif event < 0 and police_officer == 0:
		untreated += 1
print(untreated)


input()
l = list(map(int, input().split()))
s = 0
smin = 100000
for x in l[::+1]:
	s += x
	smin = min(smin, s)
print(abs(min(smin, 0)))


n = int(input())
arr = [int(x) for x in input().split()]
(sum, crime) = (0, 0)
for i in arr:
	if i >= 0:
		sum += i
	elif sum <= 0:
		crime += 1
	else:
		sum -= 1
print(crime)


n = int(input())
ar = list(map(int, input().split()))
ans = 0
bag = 0
for i in range(n):
	if ar[i] < 0 and bag == 0:
		ans += 1
	elif ar[i] < 0 and bag != 0:
		bag -= 1
	elif ar[i] > 0:
		bag += ar[i]
print(ans)


n = int(input())
x = list(map(int, input().split()))
if n == 1:
	if x[0] > -1:
		print(0)
	else:
		print(1)
else:
	s = []
	for i in x:
		if len(s) > 0:
			if i == -1 and s[-1] == -1:
				s.append(i)
			elif i == -1:
				if s[-1] == 1:
					s.pop()
				else:
					s[-1] -= 1
			elif s[-1] == -1:
				s.append(i)
			else:
				s[-1] += i
		else:
			s.append(i)
	if len(s) > 0 and s[-1] != -1:
		print(len(s) - 1)
	else:
		print(len(s))


t = int(input())
police = 0
unsolved = 0
arr = list(map(int, input().split()))
for i in range(t):
	if arr[i] > 0:
		police += arr[i]
	if arr[i] == -1:
		if police > 0:
			police -= 1
		else:
			unsolved += 1
print(unsolved)


x = int(input())
s = list(map(int, input().split()))
v = 0
u = 0
c = 0
p = 0
for n in range(x):
	if n == 0:
		if s[n] > 0:
			p = p + s[n]
		elif s[n] < 0:
			u = u + 1
	elif n != 0:
		if s[n] > 0:
			p = p + s[n]
		elif s[n] < 0:
			t = p + s[n]
			if t < 0:
				u = u + 1
			elif t >= 0:
				p = t
print(u)


n = int(input())
arr = list(map(int, input().split()))
e = 0
d = 0
for i in arr:
	if i > 0:
		d = d + i
	if i < 0 and d <= 0:
		e = e + 1
	if i < 0 and d > 0:
		d = d - 1
print(e)


def qc(v):
	(t, c) = (0, 0)
	for x in v:
		if t + x < 0:
			c += 1
		t += x
		if t < 0:
			t = 0
	return c
input()
v = [int(x) for x in input().split()]
print(qc(v))


n = int(input())
p = []
x = 0
pr = 0
p = list(map(int, input().split()))
for i in range(n):
	x += p[i]
	if x < 0:
		x = 0
		pr += 1
print(pr)


n = int(input())
liste = list(map(int, input().split()))
hired = untreated = 0
for el in liste:
	if el > 0:
		hired += el
		continue
	if hired > 0 and el < 0:
		hired -= 1
		continue
	if el < 0:
		untreated += 1
print(untreated)


n = int(input())
a = [int(x) for x in input().split()]
hired = 0
z = []
for crime in a:
	if crime < 0 and hired == 0:
		z.append(crime)
	elif hired >= 0:
		hired = hired + crime
print(-sum(z))


input()
r = t = 0
for x in map(int, input().split()):
	if x < 0:
		if not t:
			r += 1
		else:
			t -= 1
	else:
		t += x
print(r)


input()
n_crimes = 0
n_free_cops = 0
for x in (int(x) for x in input().split()):
	if x > 0:
		n_free_cops += x
	elif n_free_cops:
		n_free_cops -= 1
	else:
		n_crimes += 1
print(n_crimes)


policiais = 0
crimes = 0
saida = 0
numero = int(input())
events = [int(i) for i in input().split()]
for event in events:
	if event > 0:
		policiais += event
	elif policiais + event >= 0:
		policiais -= 1
	else:
		saida += 1
print(saida)


n = int(input())
l = list(map(int, input().split()))
sol = 0
hired = 0
untreat = 0
for i in l:
	if i > 0:
		hired += i
	elif hired > 0:
		hired = hired - abs(i)
	else:
		sol += 1
print(sol)


n = int(input())
data = [int(i) for i in input().split()]
officers = 0
unsolved = 0
for i in data:
	if i >= 1:
		officers += i
	elif officers > 0:
		officers -= 1
	else:
		unsolved += 1
print(unsolved)


n = int(input())
a = input().split()
x = 0
while x < len(a):
	a[x] = int(a[x])
	x = x + 1
c = 0
o = 0
z = 0
x = 0
while n > 0 and x < len(a):
	if a[x] == -1:
		c = o - 1
		o = o - 1
		if o < 0:
			o = 0
		if c < 0:
			z = z + 1
	else:
		o = o + a[x]
	x = x + 1
	n = n - 1
print(z)


n = int(input())
timeline = list(map(int, input().split()))
untreated = 0
available = 0
for i in timeline:
	if i < 0:
		if available > 0:
			available -= 1
		else:
			untreated += 1
	else:
		available += i
print(untreated)


input()
s = 0
p = list(map(int, input().split()))
for i in p[::-1]:
	s = min(0, s + i)
print(-s)


n = int(input())
l = list(map(int, input().split()))
crimes = 0
police = 0
i = 0
while i < len(l):
	if l[i] > 0:
		break
	crimes += 1
	i += 1
l = l[i:]
for i in l:
	if i > 0:
		police += i
	elif police > 0 and i < 0:
		police -= 1
	else:
		crimes += 1
print(crimes)


n = int(input())
a = list(map(int, input().split()))
k = 0
s1 = 0
for i in a:
	if i > 0:
		k += i
	else:
		if k + i < 0:
			s1 += k + i
		if k != 0:
			k += i
			if k < 0:
				k = 0
print(s1 * -1)


n = int(input())
a = [int(i) for i in input().split()]
p = 0
d = 0
for i in range(n):
	if a[i] != -1:
		p += a[i]
	elif p > 0:
		p -= 1
	else:
		d += 1
print(d)


n = int(input())
l = [int(x) for x in input().split()]
sum = 0
ans = 0
for i in l:
	if i == -1:
		if sum > 0:
			sum += i
		else:
			ans += 1
	else:
		sum += i
print(ans)


n = int(input())
l = list(map(int, input().split()))
res = 0
min = 0
for i in l:
	res = res + i
	if res < 0:
		if res < min:
			min = res
print(abs(min))


_ = input()
events = list(map(int, input().split()))
untcrime = 0
pc = 0
for i in events:
	if i == -1:
		if pc > 0:
			pc -= 1
		elif pc == 0:
			untcrime += 1
	elif i > 0:
		pc += i
print(untcrime)


n = int(input())
l = list(map(int, input().split()))
recruits = 0
count = 0
for e in l:
	if e == -1:
		if recruits < 1:
			count += 1
		else:
			recruits -= 1
	else:
		recruits += e
print(count)


n = int(input())
t = [int(x) for x in input().split()]
s = 0
ut = 0
for i in t:
	if s < 0:
		s = 0
	if i > 0:
		s = s + i
	if i < 0:
		s = s + i
	if s < 0:
		ut = ut + 1
print(ut)


a = int(input())
k = 0
x = 0
b = list(map(int, input().strip().split(' ')))
for i in b:
	if i > 0:
		k += i
	elif k <= 0:
		x += 1
	else:
		k -= 1
print(x)


a = input()
b = input().split()
total = 0
output = 0
for i in b:
	if total == 0 and i == '-1':
		output += 1
	else:
		total += int(i)
print(output)


n = int(input())
cr = input().strip().split(' ')
cr = [int(c) for c in cr]
fp = 0
crimes = 0
for i in range(n):
	if cr[i] == -1:
		if fp > 0:
			fp -= 1
		else:
			crimes += 1
	else:
		fp += cr[i]
print(crimes)


n = int(input())
l = list(map(int, input().split(' ')))
m = 0
o = 0
for i in l:
	m += i
	if m < 0:
		o += 1
		m = 0
print(o)


n = int(input())
l = list(map(int, input().split()))
d = {0: 0, -1: 0}
for i in l:
	if i == -1:
		if d[0] == 0:
			d[-1] += 1
		else:
			d[0] -= 1
	else:
		d[0] += i
print(d[-1])


n = int(input())
m = list(map(int, input().split()))
h = 0
u = 0
for i in m:
	h = h + i
	if h < 0:
		u = u + 1
		h = 0
print(u)


n = int(input())
status = [int(n) for n in input().split()]
count = 0
crimecount = 0
for i in range(len(status)):
	if status[i] != -1:
		count += status[i]
	if status[i] == -1 and count == 0:
		crimecount += 1
	if status[i] == -1 and count != 0:
		count -= 1
print(crimecount)


isDebug = False
n = int(input())
e = [int(x) for x in input().split()]
p = 0
t = 0
for x in e:
	if x == -1:
		if p > 0:
			p = p - 1
		else:
			t = t + 1
	else:
		p = p + x
print(f'{t}')


count = 0
n = int(input())
l = list(map(int, input().split(' ')))
ccount = 0
pcount = 0
ans = 0
for i in l:
	if i == -1:
		if pcount == 0:
			ans += 1
		else:
			pcount -= 1
	if i >= 0:
		pcount += i
print(ans)


n = int(input())
l = list(map(int, input().split()))
s = 0
ans = 0
for f in range(n):
	if l[f] > 0:
		s += l[f]
	else:
		s += l[f]
		if s < 0:
			s = 0
			ans += 1
print(ans)


number = int(input())
listaOcorrencia = [int(x) for x in input().split()]
contadorPoliciais = 0
crimesCometidos = 0
for i in listaOcorrencia:
	if i == -1:
		if contadorPoliciais == 0:
			crimesCometidos += 1
		else:
			contadorPoliciais -= 1
	else:
		contadorPoliciais += i
print(crimesCometidos)


n = input()
l = list((int(x) for x in input().split()))
police = 0
crime = 0
for x in l:
	if x < 0:
		if police == 0:
			crime += abs(x)
		else:
			police += x
	if x > 0:
		police += x
print(crime)


s = int(input())
r = list(map(int, input().split()))
police_hired = 0
crime_ocured = 0
for i in r:
	if i != -1:
		police_hired += i
	elif police_hired != 0:
		police_hired += i
	else:
		crime_ocured += 1
print(crime_ocured)


n = int(input())
t = list(map(int, input().split()))
ans = 0
recruits = 0
if t[0] == -1:
	ans += 1
else:
	recruits = t[0]
for x in range(1, len(t)):
	if t[x] == -1:
		if recruits + t[x] >= 0:
			recruits -= 1
			continue
		else:
			ans += 1
	else:
		recruits += t[x]
print(ans)


n = int(input())
s = input().split()
s = [int(i) for i in s]
i = 0
sum = 0
crimes = 0
while i != n:
	if s[i] == -1 and sum == 0:
		crimes += 1
	elif s[i] == -1 and sum > 0:
		sum -= 1
	if s[i] > 0:
		sum += s[i]
	i += 1
print(crimes)


n = int(input())
l = [int(x) for x in input().split()]
police = 0
crimes = 0
for item in l:
	if item == -1:
		if police > 0:
			police -= 1
		else:
			crimes += 1
	else:
		police += item
print(crimes)


n = int(input())
c = list(map(int, input().strip().split()))[:n]
us = 0
detectives = 0
for i in c:
	if i == -1:
		us += 1
		if detectives != 0:
			us -= 1
			detectives -= 1
	else:
		detectives += i
print(us)


n = int(input())
s = input()
a = s.split()
for i in range(len(a)):
	a[i] = int(a[i])
np = 0
sum = 0
i = 0
while i < n:
	if a[i] > 0:
		np += a[i]
	elif a[i] < 0:
		if np > 0:
			np -= 1
		else:
			sum += 1
	i += 1
print(sum)


input()
balance = unsolved_crimes = 0
for event in map(int, input().split()):
	balance += event
	if balance < unsolved_crimes:
		unsolved_crimes = balance
print(-unsolved_crimes)


n = int(input())
li = list((int(i) for i in input().split()))
(m, s) = (0, 0)
for i in li:
	if i == -1 and s == 0:
		m = m + 1
	elif i == -1:
		s = s - 1
	else:
		s = s + i
print(m)


import sys
n = int(input())
l = [int(i) for i in input().split()]
police = 0
final = 0
for i in l:
	if i < 0:
		if police == 0:
			final += 1
		else:
			police -= 1
	else:
		police += i
print(final)


num = int(input())
crimes = [int(i) for i in input().split(' ')]
count = 0
crime = 0
police = 0
for i in range(num):
	n = crimes.pop(0)
	if n == -1 and (not police):
		count += 1
	elif n == -1 and police:
		police -= 1
	else:
		police += min(10, n)
print(count)


n = int(input())
a = list(map(int, input().split()))
pol = 0
crime = 0
if 1 <= n <= 10 ** 5:
	for i in range(n):
		if a[i] == -1 and pol <= 0:
			crime += 1
		elif a[i] == -1 and pol > 0:
			pol -= 1
		else:
			pol += a[i]
	print(crime)
else:
	prinnt('Net resheenya')


n = int(input())
Events = [int(i) for i in input().split(' ')]
available_recruits = 0
untreated = 0
for E in Events:
	available_recruits += E
	if available_recruits < 0:
		untreated += 1
		available_recruits = 0
print(untreated)


n = int(input())
arr = list(map(int, input().split()))
policeCount = 0
ans = 0
for x in arr:
	if x == -1 and policeCount == 0:
		ans += 1
	elif x > 0:
		policeCount += x
	else:
		policeCount -= 1
print(ans)


n = input()
events = [int(x) for x in input().split()]
manpower = 0
untreated = 0
for x in events:
	if x == -1:
		if manpower == 0:
			untreated += 1
	manpower = max(0, manpower + x)
print(untreated)


n = int(input())
A = [int(x) for x in input().split()]
num = 0
police = 0
for i in range(n):
	if A[i] == -1:
		if police > 0:
			police -= 1
		else:
			num += 1
	else:
		police += A[i]
print(num)


a = int(input())
lst = [int(i) for i in input().split()]
s = 0
t = 0
for j in lst:
	if j == -1 and t == 0:
		s += 1
	elif j > 0:
		t += j
	elif j == -1 and t != 0:
		t -= 1
print(s)


n = int(input())
policemen = 0
unsolved = 0
for x in input().split():
	event = int(x)
	if event < 0:
		policemen -= 1
		unsolved += 1 if policemen < 0 else 0
	else:
		policemen = event + (0 if policemen < 0 else policemen)
print(unsolved)


def main():
	n = int(input())
	tasks = map(int, input().split())
	police = 0
	crimes = 0
	for task in tasks:
		if task == -1:
			if police > 0:
				police -= 1
			else:
				crimes += 1
				police = 0
		else:
			police += task
	print(crimes)
main()


n = int(input())
avlbl = 0
ans = 0
l = [int(x) for x in input().split()]
for ele in l:
	if ele >= 0:
		avlbl += ele
	elif avlbl:
		avlbl -= 1
	else:
		ans += 1
print(ans)


n = int(input())
list0 = input().split()
officers = 0
crimes = 0
for i in list0:
	if i == '-1':
		if officers == 0:
			crimes += 1
		else:
			officers -= 1
	else:
		officers += int(i)
print(crimes)


import copy

def main():
	n = int(input())
	events = [int(it) for it in input().split(' ')]
	untreated_crimes = 0
	current_police = 0
	for event in events:
		if event < 0 and current_police == 0:
			untreated_crimes = untreated_crimes + 1
		else:
			current_police = current_police + event
	print(untreated_crimes)
main()


n = int(input())
a = list(map(int, input().split()))
m = 0
d = 0
for i in a:
	if i > 0:
		m += i
	elif i < 0:
		if m > 0:
			m -= 1
		elif m == 0:
			d += 1
print(d)


n = int(input())
events = input().split(' ')
crime = 0
hire = 0
unresolved_crime = 0
for i in range(0, n):
	if int(events[i]) < 0:
		crime = crime + 1 - hire
		if crime == 0:
			hire = 0
		if crime < 0:
			hire = abs(crime)
			crime = 0
	elif int(events[i]) > 0:
		hire = int(events[i]) + hire
		unresolved_crime = unresolved_crime + crime
		crime = 0
unresolved_crime = crime + unresolved_crime
print(unresolved_crime)


n = int(input())
arr = list(map(int, input().split()))
crime = 0
icrime = 0
police = 0
ipolice = 0
for i in range(0, n):
	if arr[i] == -1:
		crime += 1
		icrime = i
	if arr[i] > 0:
		police += arr[i]
		ipolice = i
	if ipolice < icrime and police > 0:
		crime -= 1
		police -= 1
print(crime)


n = int(input())
a = list(map(int, input().split()))
p = 0
c = 0
for i in range(0, n):
	if a[i] > 0:
		p += a[i]
		continue
	if a[i] < 0 and p > 0:
		p -= 1
	else:
		c += 1
print(c)


n = int(input())
t = [int(x) for x in input().split()]
slon = 0
off = 0
for x in t:
	if x == -1 and off == 0:
		slon += 1
	elif x == -1 and off > 0:
		off -= 1
	else:
		off += x
print(slon)


n = int(input())
l = [int(x) for x in input().split()]
(p, k) = (0, 0)
for i in range(n):
	if l[i] == -1:
		i += 1
		if p == 0:
			k += 1
		else:
			p -= 1
	else:
		p += l[i]
print(k)


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


a = int(input())
s = [int(x) for x in input().split()]
c = 0
ans = 0
for i in range(a):
	c += s[i]
	if c < 0:
		ans += 1
	c = max(c, 0)
print(ans)


n = int(input())
l = list(map(int, input().split()))
i = 0
x = 0
c = 0
while i < n:
	if l[i] < 0 and x == 0:
		c = c + 1
		i = i + 1
	else:
		x = x + l[i]
		if x < 0:
			c = c + 1
		i = i + 1
print(c)


n = int(input())
l = list(map(int, input().split()))
i = 0
v = 0
a = 0
while i < len(l):
	if l[i] != -1:
		a += l[i]
	elif a == 0:
		v += 1
	else:
		a -= 1
	i += 1
print(v)


n = int(input())
l = []
a = 0
s = input().split(' ')
if len(s) != n:
	while len(s) != n:
		print('Bad!')
		s = input().split(' ')
while a < len(s):
	l.append(int(s[a]))
	a += 1
count = 0
pm = 0
i = 1
if l[0] == -1:
	count += 1
else:
	i = 0
while i < len(l):
	if l[i] > 0:
		pm += l[i]
	if l[i] == -1:
		if pm > 0:
			pm -= 1
		else:
			count += 1
	i += 1
print(count)


n = int(input())
x = list(map(int, input().split()))
res = 0
police = 0
for i in x:
	if i > 0:
		police += i
		continue
	if i < 0 and police > 0:
		police -= 1
		continue
	if i < 0 and police <= 0:
		res += 1
print(res)


n = int(input())
a = list(map(int, input().split()))
ans = 0
cnt = 0
for elem in a:
	if elem == -1 and cnt == 0:
		ans += 1
	elif elem == -1 and cnt > 0:
		cnt -= 1
	else:
		cnt += elem
print(ans)


n = int(input())
l = input().split()
for i in range(n):
	l[i] = int(l[i])
ans = 0
c = 0
for i in l:
	if i > 1 or i == 1:
		c += i
	if i == -1:
		if c > 0:
			c -= 1
		else:
			ans += 1
print(ans)


k = int(input())
b = list(map(int, input().split()))
count = 0
ans = 0
for i in b:
	if count <= 0 and i == -1:
		ans += 1
		count -= 1
	elif count > 0 and i == -1:
		count -= 1
	elif count <= 0:
		count = i
	elif count > 0:
		count += i
print(ans)


d = input()
x = input()
x = x.split(' ')
final = 0
streak = 0
for el in x:
	if int(el) >= 1:
		streak += int(el)
	elif el == '-1':
		if streak == 0:
			final += 1
		else:
			streak -= 1
print(final)


n = int(input())
x = 0
free = 0
crimes = 0
z = map(int, input().split())
for x in z:
	if x < 0:
		if free <= 0:
			crimes += abs(x)
		else:
			free -= abs(x)
	elif x > 0:
		free += x
print(crimes)


n = int(input())
a = list(map(int, input().split()))
(s, j, count) = (0, 0, 0)
for i in range(n):
	x = a.pop(0)
	if x == -1 and s == 0:
		count += 1
	elif x > 0:
		s += x
	elif x == -1 and s != 0:
		s += x
	else:
		pass
print(count)


n = int(input())
round = list(map(int, input().split()))
(unsolved_crime, pol) = (0, 0)
for i in round:
	if i != -1:
		pol += i
	if i == -1:
		if pol > 0:
			pol -= 1
		else:
			unsolved_crime += 1
print(unsolved_crime)


n = int(input())
a = list(map(int, input().split()))
(cops, answer) = (0, 0)
for i in range(n):
	if a[i] == -1 and cops == 0:
		answer += 1
	elif a[i] == -1:
		cops -= 1
	else:
		cops += a[i]
print(answer)


num = int(input())
l = input().split()
l = [int(i) for i in l]
p = 0
c = 0
total = 0
for i in l:
	if i == -1:
		p -= 1
	if i > 0:
		p += i
	if p < 0:
		p = 0
		total += 1
print(total)


n = int(input())
l = list(input().split(' '))
l = list(map(int, l))
groups = 0
takeplace = 0
for i in l:
	if i < 0:
		if groups + i >= 0:
			groups += i
		else:
			groups -= i
			takeplace = takeplace - groups
			groups = 0
	else:
		groups += i
print(-takeplace)


n = int(input())
av = cop = res = 0
s = list(map(int, input().split()))
for i in s:
	if i > 0:
		cop += i
	elif cop > 0:
		cop -= 1
	else:
		res += 1
print(res)


n = input()
arr = list(map(int, input().split()))
if not arr:
	print(0)
(cnt_pl, cnt_cr) = (0, 0)
for el in arr:
	if el < 0:
		if cnt_pl == 0:
			cnt_cr += 1
		else:
			cnt_pl -= 1
	else:
		cnt_pl += el
print(cnt_cr)


n = int(input())
arr = [int(i) for i in input().split()]
police = 0
crime = 0
for i in range(n):
	if arr[i] > 0:
		police += arr[i]
	elif police > 0:
		police -= 1
	else:
		crime += 1
print(crime)


import sys
input = sys.stdin.readline

def gl():
	return input()

def gli():
	return int(input())

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

def glm():
	return list(map(int, input().split()))
n = gli()
crime = glm()
u = 0
h = 0
for i in crime:
	if i == -1:
		if h > 0:
			h -= 1
		else:
			u += 1
	else:
		h += i
print(u)


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 [Scanner.string() 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 [Scanner.int() 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

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 solve():
	_ = Scanner.int()
	A = Scanner.map_int()
	ans = 0
	cnt = 0
	for a in A:
		if a == -1:
			if cnt > 0:
				cnt -= 1
			else:
				ans += 1
		else:
			cnt += a
	print(ans)

def main():
	solve()
main()


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
ans = polis = 0
for i in range(n):
	if a[i] == -1:
		if polis == 0:
			ans += 1
		else:
			polis -= 1
	else:
		polis += a[i]
print(ans)


n = int(input())
x = list(map(int, input().split()))
(ans, m) = (0, 0)
for a in x:
	if a > 0:
		m += a
	elif m <= 0:
		ans += 1
	else:
		m -= 1
print(ans)


n = int(input())
input_string = input()
lst = input_string.split()
ans = 0
summ = 0
for num in lst:
	if int(num) > 0:
		summ += int(num)
	elif int(num) == -1 and summ > 0:
		summ -= 1
	elif int(num) == -1 and summ == 0:
		ans += 1
print(ans)


from sys import stdin
n = int(stdin.readline())
a = list(map(int, stdin.readline().rstrip().split()))
inv = 0
count = 0
for i in a:
	if i == -1 and inv == 0:
		count += 1
	else:
		inv += i
print(count)


n = int(input())
arr = list(map(int, input().split()))
p = 0
c = 0
sum = 0
cc = 0
for i in range(n):
	if arr[i] > 0:
		p = p + arr[i]
	if p > 0 and arr[i] == -1:
		p = p - 1
	elif arr[i] == -1 and p >= 0:
		cc = cc + 1
print(cc)


num = int(input())
recruits = list(map(int, input().split()))
summ = 0
count = 0
crime = 0
for i in range(len(recruits)):
	if recruits[i] > 0:
		summ = summ + recruits[i]
	elif recruits[i] < 0 and summ <= 0:
		count -= recruits[i]
	elif recruits[i] < 0:
		summ = summ + recruits[i]
print(count)


x = int(input())
y = input().split()
z = 0
p = 0
u = 0
i = 0
while i < x:
	yy = int(y[i])
	if yy < 0:
		if p > 0:
			z = p + yy
			if z <= 0:
				u += z
				p = 0
			else:
				p = z
		else:
			u += yy
	else:
		p += yy
	i += 1
print(u * -1)


def Main():
	n = int(input())
	recs = list(map(int, input().split()))
	npol = 0
	ncr = 0
	for i in range(n):
		if recs[i] == -1:
			if npol == 0:
				ncr += 1
			else:
				npol -= 1
		else:
			npol += recs[i]
	print(ncr)
Main()


input()
(*a, r, t) = (*map(int, input().split()), 0, 0)
for x in a:
	r += x
	t += r < 0
	r = max(0, r)
print(t)


import sys
f = sys.stdin
f.readline()
a = [int(x) for x in f.readline().strip().split()]
count = 0
s = 0
for x in a:
	s += x
	if s < 0:
		count += 1
		s = 0
print(count)


n = int(input())
min = 0
q = 0
ar = list(map(int, input().split()))
for i in ar:
	q += i
	if q < min:
		min = q
print(abs(min))


n = int(input())
val = map(int, input().split())
recruits = 0
ans = 0
for a in val:
	if a == -1:
		if recruits > 0:
			recruits = recruits - 1
		else:
			ans = ans + 1
	else:
		recruits = recruits + a
print(ans)


input()
s = t = 0
a = -1
for i in input().split():
	if s < 0 and a == -1 and (int(i) > 0):
		s = 0
	s += int(i)
	if s < 0 and int(i) == -1:
		t += 1
	a = int(i)
print(t)


n = int(input())
l = list(map(int, input().split()))
h = u = 0
for e in l:
	if e > 0:
		h += e
		continue
	if h > 0 and e < 0:
		h -= 1
		continue
	if e < 0:
		u += 1
print(u)


def calculate_crimes(events):
	avail_police = 0
	crimes = 0
	for i in events:
		if i > 0:
			avail_police += i
		elif avail_police > 0:
			avail_police -= 1
		else:
			crimes += 1
	return crimes
cases = int(input())
events = list(map(int, input().split()))
print(calculate_crimes(events))


a = input()
b = [int(i) for i in input().split()]
count = 0
available = 0
for i in b:
	if i >= 1:
		available += i
	elif available > 0:
		available -= 1
	else:
		count += 1
print(count)


_ = input()
array = [int(item) for item in input().split()]
police = 0
result = 0
for item in array:
	if item == -1:
		if police < 1:
			result += 1
		else:
			police -= 1
	else:
		police += item
print(result)


n = int(input())
li = [int(i) for i in input().split()]
l = len(li)
li1 = []
li2 = []
for i in range(0, l):
	if li[i] < 0:
		li1.append(-1)
		l1 = len(li1)
		l2 = len(li2)
		if l2 > 0:
			if l1 > 0:
				li1.remove(-1)
			if l2 > 0:
				li2.remove(1)
	elif li[i] > 0:
		x = li[i]
		for j in range(x):
			li2.append(1)
L = len(li1)
print(L)


n = int(input())
officer = 0
count = 0
arr = list(map(int, input().split()))
for i in arr:
	if i >= 1:
		officer += i
	elif officer == 0:
		count += 1
	else:
		officer -= 1
print(count)


event = int(input())
arr = list(map(int, input().split()))
available_cop = 0
crime = 0
for x in range(event):
	if arr[x] > 0:
		available_cop += arr[x]
	elif available_cop > 0:
		available_cop -= 1
	else:
		crime += 1
print(crime)


number_events = input()
events = input()
events = events.split()
police = 0
crimes = 0
for x in events:
	x = int(x)
	if x > 0:
		police += x
	if x < 0:
		police -= 1
		if police < 0:
			crimes += 1
			police = 0
print(crimes)


n = int(input())
vls = list(map(int, input().split()))
(thiefs, officers) = (0, 0)
for x in vls:
	if x == -1 and officers == 0:
		thiefs += 1
	elif x == -1 and officers != 0:
		officers -= 1
	else:
		officers += x
print(thiefs)


def Police_Recruits(li):
	ans = 0
	rem_pol = 0
	for i in li:
		if i != -1:
			rem_pol += i
		elif rem_pol == 0:
			ans += abs(i)
		else:
			rem_pol += i
	ans2 = ans
	return abs(ans2)
n = input()
li = map(int, input().split())
print(Police_Recruits(list(li)))


n = int(input())
a = list(map(int, input().split()))
hired = 0
untreated = 0
for i in a:
	if i > 0:
		hired += i
		continue
	if i < 0 and hired > 0:
		hired -= 1
		continue
	if i < 0 and hired < 1:
		untreated += 1
print(untreated)


n = int(input())
event_occurence = [int(i) for i in input().split()]
police_recruit = 0
untreated = 0
for i in event_occurence:
	if i < 0:
		if police_recruit <= 0:
			untreated += 1
		else:
			police_recruit += i
	else:
		police_recruit += i
print(untreated)


def police(lst):
	c = 0
	p = 0
	for i in lst:
		if i == -1:
			if p > 0:
				p -= 1
			else:
				c += 1
		else:
			p += i
	return c
n = int(input())
lst = map(int, input().split())
print(police(lst))


n = int(input())
listy = [int(x) for x in input().split()]
police = 0
crimes = 0
for event in listy:
	if event == -1:
		if police > 0:
			police -= 1
		else:
			crimes += 1
	elif event > 0:
		police += event
print(crimes)


import re
n = int(input())
li = re.sub('[ ][1-9]+$', '', input())
li = list(map(int, li.split(' ')))
li = list(map(int, li))
crimes = 0
police = 0
res = 0
for i in li:
	if i < 0:
		crimes = 1
		if crimes > police:
			res += 1
		else:
			police -= 1
			crimes -= 1
	if i > 0:
		police += i
print(res)


n = int(input())
events = [int(i) for i in input().split()]
police = 0
crime = 0
for j in events:
	if j > 0:
		police += j
	elif j < 0 and abs(j) <= police:
		police += j
	else:
		crime += 1
print(crime)


n = int(input())
events = list(map(int, input().split()))
police = 0
occur = 0
for i in range(n):
	police += events[i]
	if police < 0:
		occur += 1
		police = 0
print(occur)


n = int(input())
moves = list(map(int, input().split()))
polices = 0
crimes = 0
for i in moves:
	if i == -1:
		if polices == 0:
			crimes += 1
		else:
			polices -= 1
	else:
		polices += i
print(crimes)


n = int(input())
summa = 0
k = 0
s = input().split()
A = list(map(int, s))
for i in range(n):
	if A[i] != -1:
		summa = summa + A[i]
	elif summa == 0:
		k = k + 1
	else:
		summa = summa - 1
print(k)


n = int(input(''))
l = list(map(int, input('').split()))
h = 0
ut = 0
for e in l:
	if e > 0:
		h += e
		continue
	elif h > 0 and e < 0:
		h -= 1
	else:
		ut += 1
print(ut)


n = int(input())
arr = list(map(int, input().split()))
c = 0
p = 0
for i in range(n):
	if arr[i] > 0:
		p += arr[i]
	elif arr[i] == -1:
		if p > 0:
			p = p - 1
			continue
		else:
			c += 1
print(c)


n = int(input())
arr = [int(x) for x in input().split()]
untreated = 0
recruits = 0
for i in range(n):
	if recruits <= 0 and arr[i] == -1:
		untreated += 1
	else:
		recruits += arr[i]
print(untreated)


n = int(input())
a = list(map(int, input().split()))
crimes = 0
current_police = 0
for i in a:
	if i == -1 and current_police == 0:
		crimes += 1
	elif i == -1 and current_police > 0:
		current_police -= 1
	else:
		current_police += i
print(crimes)


events = int(input())
string = input()
numbers = string.split(' ')
untreated = numbers.count('-1')
crimes = 0
manpower = 0
event = 0
while event < events:
	manpower += int(numbers[event])
	if numbers[event] == '-1' and manpower >= 0:
		crimes += 1
	elif manpower < 0:
		manpower = 0
	event += 1
print(untreated - crimes)


n = int(input())
events = [int(a) for a in input().split()]
cops = 0
answer = 0
for a in events:
	if a == -1 and cops == 0:
		answer += 1
	elif a == -1 and cops > 0:
		cops -= 1
	elif a != -1:
		cops += a
print(answer)


n = int(input(''))
events = list(input().split())
policeContainer = 0
crimeContainer = 0
for i in range(n):
	if int(events[i]) > 0:
		policeContainer += int(events[i])
	elif events[i] == '-1':
		if policeContainer == 0:
			crimeContainer += 1
		elif policeContainer > 0:
			policeContainer -= 1
print(crimeContainer)


n = int(input())
p = 0
s = 0
l = input().split(' ')
for i in range(len(l)):
	l[i] = int(l[i])
	if l[i] != -1:
		p = p + l[i]
	if l[i] == -1:
		if p >= 1:
			p = p - 1
		else:
			s = s + 1
print(s)


n = int(input())
c = 0
k = 0
for i in input().split():
	if int(i) > 0:
		c += int(i)
	elif int(i) == -1:
		c = int(i) + c
		if c < 0:
			k += 1
			c = 0
print(k)


n = int(input())
l = [int(X) for X in input().split()]
peo = 0
num = 0
for i in range(n):
	if l[i] == -1 and peo == 0:
		num += 1
	elif l[i] == -1:
		peo -= 1
	elif l[i] > 0:
		peo += l[i]
print(num)


n = int(input())
nums = list(map(int, input().split()))
free = 0
untreated = 0
index = 0
for i in range(n):
	if nums[i] == -1:
		untreated += 1
	elif nums[i] >= 1:
		free += nums[i]
		index = nums.index(nums[i])
	if i > index and nums[i] == -1 and (free != 0):
		free += nums[i]
		untreated -= 1
print(untreated)


_ = int(input())
crimes = 0
officers = 0
unsolved = 0
arr = input().split()
arr = [int(char) for char in arr]
for a in arr:
	if a > 0:
		officers += a
	elif officers - a >= 0:
		if officers > 0:
			officers -= 1
		else:
			unsolved += 1
print(unsolved)


import math
n = int(input())
b = list(map(int, input().split()))
s = 0
k = 0
for i in b:
	s = s + i
	if s < 0:
		k = k + abs(i)
		s = s + abs(i)
print(k)


n = int(input())
l = [int(x) for x in input().split()]
power = 0
qtd = 0
for x in l:
	if power + x < 0:
		qtd += 1
	else:
		power += x
print(qtd)


n = int(input())
z = list(map(int, input().split()))
temp = 0
count = 0
for i in range(n):
	if z[i] > 0:
		temp += z[i]
	elif temp - 1 < 0:
		count += 1
	else:
		temp -= 1
print(count)


n = int(input())
arr = list(map(int, input().split()))[:n]
pos = 0
neg = 0
ans = 0
for i in range(n):
	if arr[i] > 0:
		pos += arr[i]
	elif arr[i] < 0 and pos > 0:
		pos -= 1
	elif arr[i] < 0:
		neg += 1
if neg > 0:
	print(neg)
else:
	print(0)


events = int(input())
events = input().split()
polices = 0
un = 0
for i in events:
	i = int(i)
	if i > 0:
		polices += i
	elif polices > 0:
		polices -= 1
	else:
		un += 1
print(un)


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


n = int(input())
s = input()
s = s.split(' ')
crew = 0
unt = 0
res = 0
for i in range(n):
	temp = int(s[i])
	if temp > 0:
		crew += temp
		continue
	else:
		unt += temp
	if crew < -1 * unt:
		res += 1
		unt = 0
	else:
		crew -= 1
		unt = 0
print(res)


total_data = int(input())
data = list(map(int, input().split()))
officers = 0
crimes = 0
for i in range(len(data)):
	if data[i] == -1:
		if officers > 0:
			officers -= 1
		else:
			crimes += 1
	else:
		officers += data[i]
print(crimes)


n = int(input())
s = [int(i) for i in input().split()]
c = 0
p = 0
for i in s:
	if i > 0:
		p += i
	elif i < 0:
		if p > 0:
			p -= 1
		else:
			c += 1
print(c)


n = int(input())
ar = list(map(int, input().split()))
(pol, c) = (0, 0)
for i in ar:
	if i == -1 and pol == 0:
		c += 1
	else:
		pol += i
print(c)


n = int(input())
data = [int(i) for i in input().split(' ')]
headcount = 0
crimecount = 0
for j in data:
	if j == -1:
		if headcount == 0:
			crimecount += 1
		else:
			headcount -= 1
	else:
		headcount += j
print(crimecount)


totalCases = int(input())
mainList = list(map(int, input().split()))[:totalCases]
mainCulprits = 0
tempCount = 0
for a in mainList:
	if a >= 1:
		tempCount = tempCount + a
	elif a == -1:
		if tempCount >= 1:
			tempCount = tempCount - 1
		else:
			mainCulprits = mainCulprits + 1
print(mainCulprits)


def main():
	cops = []
	unsolved = 0
	num = int(input())
	eventArr = input()
	eventArr = eventArr.split()
	for i in range(num):
		if int(eventArr[i]) == -1:
			if not cops:
				unsolved += 1
			else:
				cops.pop()
		else:
			for j in range(int(eventArr[i])):
				cops.append(1)
	print(unsolved)
main()


n = int(input())
a = [int(i) for i in input().split()]
ans = 0
my = 0
for i in a:
	if i != -1:
		my += i
	elif i == -1 and my > 0:
		my -= 1
	else:
		ans += 1
print(ans)


n = int(input())
c = 0
d = 0
x = [int(i) for i in input().split()]
for i in x:
	if i > 0:
		c += i if i <= 10 else 10
	elif c == 0:
		d += 1
	else:
		c = c - 1
print(d)


n = int(input())
s = list(map(int, input().split()))
x = s[::-1]
a = 0
for i in x:
	a = min(0, a + i)
print(abs(a))


n = int(input())
a = input().split()
k = 0
l = 0
for i in range(n):
	if int(a[i]) == -1:
		if k > 0:
			k -= 1
		elif k == 0:
			l += 1
	elif int(a[i]) > 0:
		k += int(a[i])
print(l)


n = int(input())
X = list(map(int, input().split()))
Police = 0
crime = 0
for i in range(len(X)):
	if X[i] > 0:
		Police += X[i]
	elif Police == 0:
		crime += 1
	else:
		Police -= 1
print(crime)


n = int(input())
p = 0
sch = 0
s = list(map(int, input().split()))
for i in s:
	if i > 0:
		p += i
	elif p == 0:
		sch += 1
	else:
		p -= 1
print(sch)


def solve():
	n = input()
	events = map(int, input().split())
	crime = 0
	free = 0
	for ev in events:
		if ev > 0:
			free += ev
		elif free > 0:
			free -= 1
		else:
			crime += 1
	print(crime)
solve()


fu = input()
numbers = list(map(int, input().split()))
l = s = 0
for i in numbers:
	if l + i < s:
		s = l + i
	l += i
print(abs(s))


n = int(input())
events = [int(x) for x in input().split()]
p = 0
u = 0
for e in events:
	if e > 0:
		p += e
	elif p > 0:
		p -= 1
	else:
		u += 1
print(u)


numb = input()
police = 0
crime = 0
events = [int(a) for a in input().split()]
for event in events:
	if event > 0:
		police += event
	elif police > 0:
		police -= 1
	else:
		crime += 1
print(crime)


n = int(input())
po = list(map(int, input().split(' ')))
curOff = 0
unt = 0
for i in po:
	if i != -1:
		curOff += i
	elif curOff == 0:
		unt += 1
	else:
		curOff += i
print(unt)


n = int(input())
totale = 0
minik = 0
listed = list(map(int, input().split()))
for i in range(len(listed)):
	totale += listed[i]
	if totale < 0 and minik > totale:
		minik = totale
print(abs(minik))


def solve(events):
	hired = 0
	count = 0
	for event in events:
		if event > 0:
			hired += event
		elif event < 0 and hired > 0:
			hired += event
		elif event < 0:
			count += event
	return abs(count)
number = input()
print(solve(list(map(int, input().split()))))


y = int(input())
lst = list(map(int, input().split()))
count = 0
checker = 0
for i in range(0, len(lst)):
	if lst[i] > 0:
		count += lst[i]
	elif lst[i] < 0 and count == 0:
		checker += 1
	elif lst[i] < 0 and count != 0:
		count -= 1
print(checker)


input()
a = input().split()
(f, c) = (0, 0)
for i in a:
	if f == 0 and i == '-1':
		c += 1
	else:
		f += int(i)
print(c)


n = int(input())
l = list(map(int, input().split()))
noOfPolice = noOfUn = 0
for i in range(n):
	if l[i] > 0 and l[i] <= 10:
		noOfPolice += l[i]
	elif l[i] < 0:
		if noOfPolice >= 1:
			noOfPolice -= 1
		else:
			noOfUn += 1
print(noOfUn)


def recruits(l):
	r = 0
	c = 0
	for e in l:
		if e > 0:
			r += e
		elif r > 0:
			r -= 1
		else:
			c += 1
	return c
n = int(input().strip())
l = list(map(int, input().strip().split()))
print(recruits(l))


n_events = int(input())
e_type = list(map(int, input().split(' ')))
available_officer = 0
untreated = 0
for i in e_type:
	if i == -1:
		if available_officer == 0:
			untreated += 1
		else:
			available_officer -= 1
	else:
		available_officer += i
print(untreated)


(z, pr) = (0, 0)
n = input()
x = input().split(' ')
for a in x:
	a = int(a)
	if a < 0:
		if pr == 0:
			z = z + 1
		else:
			pr = pr - 1
	elif a > 10:
		pr = pr + 10
	else:
		pr = pr + a
print(z)


import math
import os
import sys
import re
import string
import itertools
import functools
import operator
n = int(input())
(res, num) = (0, 0)
for i in map(int, input().split()):
	if i == -1:
		if num == 0:
			res = res + 1
		num = max(num - 1, 0)
	else:
		num = num + i
print(res)


a = int(input())
b = list(map(int, input().split()))
c = 0
d = 0
for i in b:
	if i > 0:
		c += i
	else:
		c = c + i
		if c < 0:
			c = 0
			d += 1
print(d)


n = int(input())
string = input().split(' ')
current = 0
untreated = 0
for item in string:
	if item == '-1':
		if current <= 0:
			untreated += 1
		else:
			current -= 1
	else:
		current += int(item)
print(str(max(0, untreated)))


n = int(input())
events = list(map(int, input().split()))
crimesunt = 0
currentpol = 0
for e in events:
	currentpol += e
	if currentpol < 0:
		crimesunt += 0 - currentpol
		currentpol = 0
print(crimesunt)


n = int(input())
l = [int(x) for x in input().split(' ')[:n]]
sum = 0
c = 0
for i in range(n):
	sum = sum + l[i]
	if sum < 0:
		c += 1
		sum = 0
print(c)


n = input()
a = list(input().split())
l = 0
m = 0
for i in a:
	if m == 0 and i == '-1':
		l += 1
	else:
		m += int(i)
print(l)


from fractions import Fraction
import sys
import bisect
import heapq
from math import *
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
import statistics
from statistics import mode
from functools import reduce
mod = 1000000007

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

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 graph(vertex):
	return [[] for i in range(0, vertex + 1)]

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 lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def most_frequent(List):
	occurence_count = Counter(List)
	return occurence_count.most_common(1)[0][0]

def most_common(List):
	return mode(List)

def chinese_remainder(a, p):
	prod = reduce(op.mul, p, 1)
	x = [prod // pi for pi in p]
	return sum((a[i] * pow(x[i], p[i] - 2, p[i]) * x[i] for i in range(len(a)))) % prod

def createMatrix(rowCount, colCount, dataList):
	mat = []
	for i in range(rowCount):
		rowList = []
		for j in range(colCount):
			if dataList[j] not in mat:
				rowList.append(dataList[j])
		mat.append(rowList)
	return mat

def isprime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
import collections

def minimalFilps1(bits):
	n = len(bits)
	flipsFromLeft = [0 for i in range(n)]
	flipsFromRight = [0 for i in range(n)]
	flips = 0
	for i in range(0, n, 1):
		if bits[i] == '1':
			flips = flips + 1
		flipsFromLeft[i] = flips
	flips = 0
	i = n - 1
	while i >= 0:
		if bits[i] == '0':
			flips = flips + 1
		i = i - 1
		flipsFromRight[i] = flips
	minFlips1 = sys.maxsize
	for i in range(1, n, 1):
		if flipsFromLeft[i - 1] + flipsFromRight[i] < minFlips1:
			minFlips1 = flipsFromLeft[i - 1] + flipsFromRight[i]
	return minFlips1

def minimalFilps(bits):
	n = len(bits)
	flipsFromLeft = [0 for i in range(n)]
	flipsFromRight = [0 for i in range(n)]
	flips = 0
	for i in range(0, n, 1):
		if bits[i] == '0':
			flips = flips + 1
		flipsFromLeft[i] = flips
	flips = 0
	i = n - 1
	while i >= 0:
		if bits[i] == '1':
			flips = flips + 1
		i = i - 1
		flipsFromRight[i] = flips
	minFlips = sys.maxsize
	for i in range(1, n, 1):
		if flipsFromLeft[i - 1] + flipsFromRight[i] < minFlips:
			minFlips = flipsFromLeft[i - 1] + flipsFromRight[i]
	return minFlips

def oddn(n):
	for i in range(2, n + 1):
		if i % 2 != 0 and n % i == 0:
			return i
	return 3

def memoized(*args):
	if args in stored_results:
		return stored_results[args]
	else:
		result = stored_results[args] = fn(*args)
		return result
	return memoized
open_list = ['(']
close_list = [')']

def check(myStr):
	stack = []
	e = 0
	for i in myStr:
		if i in open_list:
			stack.append(i)
		elif i in close_list:
			pos = close_list.index(i)
			if len(stack) > 0:
				stack.pop()
				e += 1
	return e
n = int(input())
a = list(map(int, input().split()))
b = []
c = 0
for i in range(n):
	if a[i] > 0:
		b.append(a[i])
	elif len(b) == 0:
		c += 1
	else:
		d = b.pop()
		d -= 1
		if d > 0:
			b.append(d)
print(c)
import operator
open_list = ['(']
close_list = [')']

def check(myStr):
	stack = []
	e = 0
	for i in myStr:
		if i in open_list:
			stack.append(i)
		elif i in close_list:
			pos = close_list.index(i)
			if len(stack) > 0:
				stack.pop()
				e += 1
	return e


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


n = int(input())
events = input().split()
free_oficers = 0
untreated_crimes = 0
for e in events:
	if e == '-1':
		if free_oficers > 0:
			free_oficers -= 1
		else:
			untreated_crimes += 1
	else:
		free_oficers += int(e)
print(untreated_crimes)


x = int(input())
n = list(map(int, input().split()))
h = 0
ut = 0
for i in n:
	if i > 0:
		h += i
		continue
	if h > 0 and i < 0:
		h -= 1
		continue
	if i < 0:
		ut += 1
print(ut)


number_of_events = int(input())
operations = input().split(' ')
crimes_forever = 0
number_of_policemen = 0
for i in range(number_of_events):
	if int(operations[i]) < 0:
		if number_of_policemen > 0:
			number_of_policemen -= 1
		else:
			crimes_forever += 1
	else:
		number_of_policemen += int(operations[i])
print(crimes_forever)


N = int(input())
timeline = list(map(int, input().split(' ')))
free_officers = 0
crimes_untreated = 0
for t in timeline:
	if t == -1:
		if free_officers > 0:
			free_officers -= 1
		else:
			crimes_untreated += 1
	else:
		free_officers += t
print(crimes_untreated)


n = int(input())
li = [int(i) for i in input().split()]
p = 0
c = 0
for i in range(n):
	if li[i] == -1:
		c = c + 1
		if p != 0:
			p = p - 1
			c = c - 1
	elif li[i] >= 0:
		p = p + li[i]
print(c)


def police_recruit(a):
	police = 0
	untreat = 0
	for i in range(len(a)):
		if a[i] == -1:
			if police > 0:
				police = police - 1
			else:
				untreat = untreat + 1
		else:
			police = police + a[i]
	print(untreat)
n = int(input(''))
a = list(map(int, input('').split()))
police_recruit(a)


input()
n = list(map(int, input().split()))
c = counter = 0
for i in n:
	c += i
	if c == -1:
		counter += 1
		c = 0
print(counter)


n = int(input())
e = [int(i) for i in input().split()]
p = 0
c = 0
for i in range(len(e)):
	if e[i] > 0:
		p += e[i]
	elif p == 0:
		c += 1
	else:
		p -= 1
print(c)


n = input()
array = [int(i) for i in input().split(' ')]
free = 0
count = 0
for num in array:
	if num != -1:
		free += num
	elif free > 0:
		free -= 1
	else:
		count += 1
print(count)


n = int(input())
(police, crime) = (0, 0)
l = list(map(int, input().split()))
for oc in l:
	if oc != -1:
		police += oc
	elif police <= 0:
		crime += 1
	else:
		police -= 1
print(crime)


from sys import stdin, stdout
number_of_policies = int(stdin.readline())
policies = list(map(int, stdin.readline().split()))
i = 0
police_on_service = 0
untreated = 0
while i < number_of_policies:
	if policies[i] != -1:
		police_on_service += policies[i]
	elif police_on_service == 0:
		untreated += 1
	else:
		police_on_service -= 1
	i += 1
stdout.write(str(untreated) + '\n')


def police(n, a):
	count = 0
	p = 0
	for i in range(0, n):
		if a[i] > 0:
			p = p + a[i]
		elif p == 0 and a[i] < 0:
			count = count + 1
		elif p != 0 and a[i] < 0:
			p = p - 1
	print(count)
n = int(input())
list1 = [int(i) for i in input().split()]
police(n, list1)


n = int(input())
a = list(map(int, input().split()))
crime = 0
police = 0
for i in range(n):
	if a[i] < 0:
		if police >= -a[i]:
			police -= -a[i]
		else:
			crime = crime - police + -a[i]
			police = 0
	if a[i] > 0:
		police += a[i]
print(abs(crime))


N = int(input())
crimes_lis = input().split()
crimes_lis = list(map(int, crimes_lis))
heired = 0
untreated = 0
for i in range(N):
	if crimes_lis[i] == abs(crimes_lis[i]):
		heired += crimes_lis[i]
		continue
	if heired > 0 and crimes_lis[i] != abs(crimes_lis[i]):
		heired -= 1
		continue
	if heired == 0 and crimes_lis[i] != abs(crimes_lis[i]):
		untreated += 1
print(untreated)


n = int(input())
m = list(map(int, input().split()))
(x, count) = (0, 0)
for i in range(n):
	if m[i] < 0 and x <= 0:
		count += 1
		x = 0
	elif m[i] < 0 and x > 0:
		x = x + m[i]
		continue
	else:
		x += m[i]
print(count)


n = int(input())
li = list(map(str, input().split()))
crimes = 0
rec = 0
i = 0
while i < n:
	if li[i] == '-1' and rec == 0:
		crimes = crimes + 1
	elif li[i] == '-1' and rec != 0:
		rec = rec - 1
	elif li[i] != '-1':
		rec = rec + int(li[i])
	i = i + 1
print(crimes)


x = int(input())
a = input().split()
t = 0
k = 0
for i in a:
	if t + int(i) < 0:
		k += 1
	else:
		t += int(i)
print(k)


n = int(input())
power = 0
tot = 0
c = input().split()
for i in range(0, len(c)):
	x = int(c[i])
	if x > 0:
		power += x
	elif x < 0:
		if power == 0:
			tot += 1
		else:
			power -= 1
print(tot)


n = int(input())
a = [int(_) for _ in input().split()]
cnt = 0
cur = 0
for x in a:
	if x < 0:
		if cur == 0:
			cnt += 1
		else:
			cur -= 1
	else:
		cur += x
print(cnt)


n = int(input())
events = list(map(int, input().split()))
recruit = 0
ans = 0
for x in range(n):
	if events[x] == -1:
		if recruit < 1:
			ans += 1
		else:
			recruit -= 1
	else:
		recruit += events[x]
print(ans)


N = int(input())
a = list(map(int, input().strip().split()))
a += [0] * N
i = 0
p = a[i]
crime = 0
while i <= N - 1:
	if p > 0:
		p += a[i + 1]
		i += 1
	elif p < 0:
		crime += 1
		i += 1
		p = a[i]
	else:
		i += 1
		p = a[i]
print(crime)


x = int(input())
y = list(map(int, input().split()))
count = 0
sum = 0
for i in y:
	if i > 0:
		sum = sum + i
	elif sum > 0:
		sum = sum - 1
	else:
		count = count + 1
print(count)


no_of_events = int(input())
events = input()
events_list = list(events.split())
available_officer = 0
untreated_crimes = 0
for event in events_list:
	if event == '-1':
		if not available_officer:
			untreated_crimes += 1
		else:
			available_officer -= 1
	else:
		available_officer += int(event)
print(untreated_crimes)


n = int(input())
s = input().split(' ')
person = 0
crime = 0
for i in range(n):
	person += int(s[i])
	if person < 0:
		person += 1
		crime += 1
print(crime)


input()
s = [int(x) for x in input().split()]
police = untreated = 0
for i in s:
	if i > 0:
		police += i
	elif police > 0:
		police -= 1
	else:
		untreated += 1
print(untreated)


size = int(input())
arr = [int(x) for x in input().split()]
totCrimes = 0
totAvailablePoliceOfficers = 0
for i in range(size):
	if arr[i] > 0:
		totAvailablePoliceOfficers += arr[i]
	elif totAvailablePoliceOfficers > 0:
		totAvailablePoliceOfficers -= 1
	else:
		totCrimes += 1
print(totCrimes)


n = int(input())
a = list(map(int, input().strip().split()))[:n]
ans = 0
curr = 0
for i in a:
	curr += i
	if curr < 0:
		ans += abs(curr)
		curr = 0
print(ans)


n = int(input())
l = list(map(int, input().split()))
count = 0
counter = 0
for i in l:
	if i == -1:
		if counter > 0:
			counter -= 1
		else:
			count += 1
	else:
		counter += i
print(count)


n = int(input())
l = list(map(int, input().split()))
po = 0
un = 0
for e in l:
	if e > 0:
		po += e
	if po == 0 and e == -1:
		un += 1
	if po > 0 and e == -1:
		po -= 1
print(un)


n = int(input())
arr = list(map(int, input().split()))
r = o = 0
for i in range(n):
	if arr[i] == -1 and o == 0:
		r += 1
	elif arr[i] == -1 and o > 0:
		o -= 1
	else:
		o += arr[i]
print(r)


n = int(input())
l = [int(x) for x in input().split()]
(nuc, p) = (0, 0)
for i in l:
	if i > 0:
		p += i
	elif p == 0:
		nuc += i
	elif p > 0:
		p -= 1
print(abs(nuc))


t = int(input())
li = list(map(int, input().split(' ')))
i = 0
police = 0
crimes = 0
while i < t:
	if li[i] == -1:
		police -= 1
		if police < 0:
			police = 0
			crimes += 1
	else:
		police += li[i]
	i += 1
print(crimes)


a = int(input())
b = input()
c = b.split()
d = []
for i in c:
	d.append(int(i))
count = 0
n_pol = 0
for k in d:
	if k < 0:
		if n_pol + k < 0:
			count += 1
		else:
			n_pol -= 1
	else:
		n_pol += k
print(count)


n = int(input())
l = [int(x) for x in input().split()]
if len(l) != n:
	exit(1)
p = 0
c = 0
for x in l:
	if x == -1 and c == 0 and (p == 0):
		c += 1
	elif x == -1:
		if p >= 1:
			p -= 1
		else:
			c += 1
	else:
		p += x
print(c)


n = input()
n = int(n)
x = list(map(int, input().split()))
g = 0
p = 0
for i in x:
	p += i
	if p < 0:
		g += 1
		p = 0
print(g)


n = int(input())
hc = list(map(int, input().split()))
hirings = crimes = crime_count = 0
for i in hc:
	if i > 0:
		hirings += i
	else:
		crimes += 1
		if hirings > 0:
			hirings -= 1
			crimes -= 1
		else:
			crime_count += 1
print(crime_count)


n_events = int(input())
events = [int(x) for x in input().split()]
curr_recruits = 0
untreat_crimes = 0
for j in events:
	if j == -1 and curr_recruits == 0:
		untreat_crimes += 1
	elif j == -1:
		curr_recruits -= 1
	else:
		curr_recruits += j
print(untreat_crimes)


n = int(input())
ans = 0
b = []
num = list(map(int, input().split()))
for i in range(n):
	ans += num[i]
	b.append(ans)
print([0, abs(min(b))][min(b) <= 0])


n = int(input())
s = list(map(int, input().split()))
ans = 0
t = 0
for i in s:
	t += i
	if t < 0:
		ans += abs(t)
		t = 0
print(ans)


n = int(input())
arr = list(map(int, input().split()))
ans = 0
count = 0
for i in arr:
	if i == -1 and ans == 0:
		count += 1
	else:
		ans += i
print(count)


a = input()
x = input()
x = x.split()
c = 0
b = 0
for i in x:
	if int(i) < 0 and c == 0:
		b = b + abs(int(i))
	elif int(i) < 0 and c > 0:
		c = c - abs(int(i))
	elif int(i) > 0:
		c = c + abs(int(i))
print(b)


n = int(input())
crime = [int(n) for n in input().split()]
count = 0
available = 0
for i in range(n):
	if crime[i] == -1 and available != 0:
		available = available - 1
	elif crime[i] == -1 and available == 0:
		count = count + 1
	elif crime[i] > 0:
		available = available + crime[i]
print(count)


n = int(input())
crimes_list = map(int, input().split())
crimes = 0
temp = 0
for i in crimes_list:
	if temp <= 0 and i == -1:
		crimes += 1
	else:
		temp += i
print(crimes)


n = int(input())
lis = [int(x) for x in input().split()]
sum = 0
co = 0
for i in lis:
	if i > 0:
		sum += i
	elif sum > 0:
		sum -= 1
	else:
		co += 1
print(co)


n = int(input())
events = list(map(int, input().split()))
buf = 0
crimes = 0
for x in events:
	if x == -1:
		if buf == 0:
			crimes += 1
		else:
			buf -= 1
	else:
		buf += x
print(crimes)


import sys
input = sys.stdin.readline

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

def inlt():
	return list(input().split())

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

def invr():
	return int(input()).split()
x = inp()
y = inlt()
police = 0
crime = 0
totunt = 0
y = [int(i) for i in y]
for ei in y:
	if ei >= 1:
		police += ei
	else:
		crime += 1
		police = police - 1
		if police < 0:
			totunt += 1
			crime = crime - 1
			police = 0
		else:
			crime = crime - 1
print(totunt)


hm = int(input())
events = input().split(' ')
police = 0
crime = 0
for i in range(hm):
	events[i] = int(events[i])
for i in range(hm):
	if events[i] > 0:
		police += events[i]
	if events[i] == -1 and police == 0:
		crime += 1
	elif events[i] == -1 and police > 0:
		police -= 1
print(crime)


n = int(input())
p = 0
lst = [int(i) for i in input().split()]
nd = 0
for i in lst:
	if i < 0:
		if p - 1 < 0:
			nd += 1
		elif p - 1 >= 0:
			p = p - 1
	else:
		p = p + i
print(nd)


n = int(input())
l = list(map(int, input().split()))
(f, c, p) = (0, 0, 0)
for i in range(len(l)):
	if l[i] == -1 and f == 0:
		c += 1
	if l[i] > 0:
		f = 1
		p += l[i]
	if l[i] == -1 and f == 1 and (p > 0):
		p -= 1
		if p == 0:
			f = 0
print(c)


n = int(input())
a = list(map(int, input().split()))
p = 0
w = 0
q = 0
for i in range(n):
	if a[i] == -1:
		q = i
for i in range(q + 1):
	if a[i] == -1:
		if p >= 1:
			p -= 1
		else:
			w -= 1
	else:
		p += a[i]
print(abs(w))


n = int(input())
plc = input().split()
count = 0
summ = 0
for i in range(n):
	if int(plc[i]) > 0:
		summ = summ + int(plc[i])
	elif summ > 0:
		summ = summ - 1
	else:
		count = count + 1
print(count)


n = int(input())
d = [int(x) for x in input().split()]
c = 0
o = 0
u = 0
for x in d:
	if x == -1:
		if o > 0:
			o -= 1
		else:
			u += 1
	else:
		o += x
print(abs(u))


n = int(input())
list1 = list(map(int, input().split()))
pos = 0
neg = 0
for i in list1:
	if i > 0:
		pos = pos + i
		continue
	if i < 0 and pos > 0:
		pos = pos - 1
		continue
	if i < 0:
		neg = neg + 1
print(neg)


n = int(input())
l = map(int, input().split())
s = 0
Nb = 0
for i in l:
	if i > 0:
		s += i
	else:
		s -= 1
		if s == -1:
			Nb += 1
			s = 0
print(Nb)


n = int(input())
m = list(map(int, input().split()))
s = 0
d = 0
for i in range(len(m)):
	s += m[i]
	if s < 0:
		s = 0
		d += 1
print(d)


import math
from collections import *
import sys
from functools import reduce

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0)
n = int(input())
li = get_list()
man = 0
ans = 0
for i in li:
	if i == -1:
		if man > 0:
			man -= 1
		else:
			ans += 1
	else:
		man += i
print(ans)


n = int(input())
a = input().split()
b = []
for i in a:
	b.append(int(i))
counter = 0
l = []
for i in b:
	if i < 0 and counter == 0:
		l.append(i)
	elif i > 0:
		counter += i
	else:
		counter = counter + i
print(abs(sum(l)))


e = int(input())
lst = list(map(int, input().split()))
c = 0
v = 0
for i in range(len(lst)):
	if lst[i] != -1:
		v = v + lst[i]
	elif v + lst[i] < 0:
		c = c + 1
	elif v + lst[i] >= 0:
		v = v + lst[i]
print(c)


n = int(input())
l = list(map(int, input().rstrip().split()))
pol = 0
untrt = 0
for i in range(0, len(l)):
	if i == 0:
		if l[i] == -1:
			untrt += 1
		if l[i] > 0:
			pol = l[i]
	elif l[i] == -1:
		if pol > 0:
			pol = pol - 1
		else:
			untrt += 1
	elif l[i] > 0:
		pol += l[i]
print(untrt)


def solve(arr):
	ans = 0
	temp = 0
	for i in arr:
		if i < 0:
			if temp == 0:
				ans += 1
			else:
				temp -= 1
		else:
			temp += i
	return ans
input()
print(solve(list(map(int, input().split(' ')))))


num = int(input())
events = list(input().split())
count = 0
crimes = 0
for i in range(len(events)):
	if int(events[i]) > 0:
		count = count + int(events[i])
	if int(events[i]) == -1:
		count = count - 1
		if count < 0:
			crimes = crimes + 1
			count = count + 1
print(crimes)


a = input()
a = int(a)
b = input()
b = b.split()
c = list()
for x in b:
	c.append(int(x))
cr = 0
po = 0
for x in c:
	if x == -1 and po == 0:
		cr += 1
	elif x == -1 and po > 0:
		po -= 1
	elif x > 0:
		po += x
print(cr)


n = int(input())
list_ = list(map(int, input().split()))
(f, ans) = (0, 0)
for i in list_:
	if i == -1:
		if not f:
			ans += 1
		else:
			f -= 1
	else:
		f += i
print(ans)


n = int(input())
a = list(map(int, input().split()))
count2 = 0
count1 = 0
for i in range(n):
	if a[i] > 0:
		count2 = count2 + a[i]
	elif a[i] == -1:
		if count2 > 0:
			count2 = count2 - 1
		elif count2 == 0:
			count1 = count1 + 1
print(count1)


n = int(input())
l = list(map(int, input().split()))
s = 0
count = 0
for i in l:
	if i != -1:
		s += i
	elif s > 0:
		s -= 1
	else:
		count += 1
print(count)


n = int(input())
numbers = (int(num) for num in input().split(' ', n - 1))
prestuplenie = 0
policai = 0
for i in numbers:
	if i < 0 and policai <= 0:
		prestuplenie += 1
	elif i < 0 and policai > 0:
		policai -= 1
	elif i > 0:
		policai += i
print(prestuplenie)


n = int(input())
a = eval(input().rstrip().replace(' ', ',') + ',')
untreated = 0
officers = 0
for num in a:
	if num == -1:
		if officers > 0:
			officers -= 1
		else:
			untreated += 1
	else:
		officers += num
print(untreated)


k = int(input())
l = list(map(int, input().split()))
z = 0
d = 0
for i in l:
	if i == -1:
		if z == 0:
			d += 1
		else:
			z -= 1
	else:
		z += i
print(d)


n = int(input())
li = list(map(int, input().split()))
c = p = 0
for i in li:
	if i > 0:
		p += i
		continue
	if p > 0 and i < 0:
		p -= 1
		continue
	if i < 0 and p <= 0:
		c += 1
print(c)


input()
pc = map(int, input().split())
p = c = 0
for i in pc:
	if i > 0:
		p += i
	elif p == 0:
		c += 1
	else:
		p += i
print(c)


N = int(input())
L = []
L = input().split()
A = 0
B = 0
for k in L:
	c = int(k)
	if c > 0:
		A += c
	elif c == -1:
		if A > 0:
			A -= 1
		else:
			B += 1
print(B)


import sys
input = sys.stdin.readline

def main():
	n = inp()
	unsolved = 0
	police = 0
	for e in inlt():
		if e > 0:
			police += e
		elif e < 0 and police == 0:
			unsolved += 1
		elif e < 0 and police > 0:
			police -= 1
		else:
			unsolved += 1
	print(unsolved)

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

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

def instr():
	return ''.join(insr())

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

def invr():
	return map(int, input().split())
main()


num_events = int(input())
events = [int(a) for a in input().split()]
unsolved = 0
status = 0
for event in events:
	if event == -1:
		status -= 1
		if status < 0:
			unsolved -= status
			status = 0
	else:
		status += event
print(unsolved)


n = int(input())
a = list(map(int, input().split()))
crimes = 0
police = 0
for x in a:
	if x == -1 and police == 0:
		crimes += 1
	elif x == -1 and police > 0:
		police -= 1
	elif x >= 1:
		police += x
print(crimes)


import sys
n = input()
a = map(int, input().split())
ans = 0
s = 0
for x in a:
	if x == -1:
		if s > 0:
			s -= 1
		else:
			ans += 1
	else:
		s += x
print(ans)


input()
m = 0
a = list(map(int, input().split()))
k = len(a)
w = 0
for i in range(k):
	if a[i] > 0:
		w += a[i]
	if a[i] < 0:
		if w > 0:
			w -= 1
		else:
			m += 1
print(m)


n = int(input())
xs = [int(x) for x in input().split(' ')]
p = 0
u = 0
for i in range(len(xs)):
	if xs[i] > 0:
		p += xs[i]
	elif p > 0:
		p -= 1
	else:
		u += 1
print(u)


n = int(input())
x = list(map(int, input().split()))
crime = 0
free = 0
for each in x:
	if each == -1:
		if not free:
			crime += 1
		else:
			free -= 1
	else:
		free += each
print(crime)


n = int(input())
t = list(map(int, input().split()))
temp = 0
ans = 0
for i in t:
	if i < 0:
		temp += i
		if temp < 0:
			ans -= temp
			temp = 0
	else:
		temp += i
print(ans)


n = int(input())
l = [int(x) for x in input().split()]
ans = 0
cur = 0
for x in l:
	if x > 0:
		cur += x
	if x < 0:
		cur -= 1
		if cur < 0:
			cur = 0
			ans += 1
print(ans)


n = int(input())
a = [int(a) for a in input().split()]
count = 0
b = 0
for i in range(n):
	b = b + a[i]
	if b < 0:
		count += 1
		b = 0
print(count)


n = input()
a = list(input().split())
k = 0
r = 0
for i in a:
	if r == 0 and i == '-1':
		k += 1
	else:
		r += int(i)
print(k)


dni = int(input())
akcie = list(map(int, input().split()))
(policajtov, untreated) = (0, 0)
for i in range(dni):
	akcia = akcie[i]
	if akcia == -1:
		if policajtov > 0:
			policajtov -= 1
		else:
			untreated += 1
	else:
		policajtov += akcia
print(untreated)


input()
li = list(map(int, input().split()))
ans = 0
cnt = 0
for i in li:
	ans += i
	if ans < 0:
		ans = 0
		cnt += 1
print(cnt)


n = int(input())
s = [int(i) for i in input().split()]
a = 0
c = 0
for i in range(n):
	if s[i] > 0 and a < 0:
		a = 0
	a = a + s[i]
	if a < 0:
		c = c + 1
print(c)


size = int(input(''))
a = input('')
na = len(a)
b = []
i = 0
for j in range(size):
	if a[i] != '-':
		if i + 1 <= na - 1:
			if a[i + 1] == '0':
				k = a[i]
				b.insert(j, int(k) * 10)
				i = i + 3
			else:
				k = a[i]
				b.insert(j, int(k))
				i = i + 2
		else:
			k = a[i]
			b.insert(j, int(k))
			i = i + 2
	else:
		i = i + 1
		k = int(a[i]) * -1
		b.insert(j, k)
		i = i + 2
d = 0
e = 0
for i in range(size):
	d = d + b[i]
	if d < 0:
		e += 1
		d = 0
print(e)


n = int(input())
a = list(input().split())
c = 0
p = 0
t = 0
e = 0
for i in range(n):
	if int(a[i]) > 0:
		c = c + int(a[i])
	else:
		p = p + int(a[i])
	if p > 0:
		p = c - p
	if p + c < e:
		e = p + c
print(abs(e))


n = int(input())
a = list(map(int, input().split()))
c = b = 0
for i in a:
	if b == 0 and i == -1:
		i = False
		c = c + 1
	elif b > 0 and i == -1:
		b = b - 1
	else:
		b = b + i
print(c)


n = int(input())
n2 = list(map(int, input().split()))[::-1]
x = 0
for i in n2:
	x = min(0, x + i)
print(-x)


a = int(input())
b = list(map(int, input().split()))
police = 0
crime = 0
for i in b:
	if i != -1:
		police += i
	elif police <= 0:
		crime += 1
	else:
		police -= 1
print(crime)


n = input()
seq = [int(i) for i in input().split(' ')]
hired = 0
crimes = 0
untreated = 0
for i in range(int(n)):
	if seq[i] > 0:
		hired += seq[i]
		crimes = 0
	elif seq[i] < 0:
		crimes += 1
		if hired > 0:
			hired -= 1
			crimes -= 1
		else:
			untreated += crimes
			crimes = 0
print(untreated)


n = input()
s = input().split()
count = 0
per = 0
for i in range(len(s)):
	if int(s[i]) > 0:
		per += int(s[i])
	elif s[i] == '-1' and per == 0:
		count += 1
	else:
		per -= 1
print(count)


x = int(input())
l = list(map(int, input().split()))
c = 0
o = 0
for i in l:
	if i != -1:
		o += i
	elif o == 0:
		c += i
	else:
		c += i + 1
		o -= 1
print(-c)


n = int(input())
lst = [int(x) for x in input().split()]
curr = 0
untreated = 0
for i in lst:
	if curr < 1 and i == -1:
		untreated += 1
	elif curr >= 1 and i == -1:
		curr -= 1
	else:
		curr += i
print(untreated)


n = int(input())
s = input().split()
lst1 = list()
for i in range(n):
	lst1.append(int(s[i]))
s1 = 0
x = 0
for i in range(n):
	if lst1[i] > 0 or s1 > 0:
		s1 += lst1[i]
	else:
		x += lst1[i]
print(abs(x))


n = int(input())
a = [int(x) for x in input().split()]
r = 0
ans = 0
for j in a:
	if j == -1:
		if r > 0:
			r -= 1
		elif r == 0:
			ans += 1
	else:
		r += j
print(ans)


n = int(input())
num = input()
arr = []
count = 0
for i in range(0, len(num)):
	if num[i] == ' ':
		arr.append(int(num[count:i]))
		count = i + 1
	elif i == len(num) - 1:
		arr.append(int(num[count:len(num)]))
current_recuit = 0
crime = 0
for i in arr:
	if i < 0:
		n = current_recuit + i
		if n < 0:
			crime += 1
		else:
			current_recuit += i
	elif i > 0:
		current_recuit += i
print(crime)


n = int(input())
events = list(map(int, input().split()))
untreated = 0
officers = 0
for e in events:
	if e == -1:
		if officers >= 1:
			officers -= 1
		else:
			untreated += 1
	else:
		officers += e
print(untreated)


N = int(input())
E = list(map(int, input().split()))
P = 0
C = 0
for event in E:
	if event == -1:
		if P > 0:
			P -= 1
		else:
			C += 1
	else:
		P += event
print(C)


n = int(input())
s = [int(i) for i in input().split()]
res = 0
cops = 0
for i in s:
	if i > 0:
		cops += i
	elif i == -1:
		if cops > 0:
			cops -= 1
		else:
			res += 1
print(res)


def inlt():
	return list(map(int, input().split()))
n = int(input())
s = inlt()
c = 0
ans = 0
for i in range(n):
	if s[i] == -1 and c == 0:
		ans += 1
	c = max(0, c + s[i])
print(ans)


x = input()
l = list(map(int, input().split()))
crimes = 0
stock = 0
crime_rate = 0
for i in range(len(l)):
	if l[i] == -1:
		if stock > 0:
			stock -= 1
		else:
			crimes += 1
	else:
		stock += l[i]
print(crimes)


a = int(input())
b = list(map(int, input().split()))
(p, count) = (0, 0)
for i in range(a):
	if b[i] > 0:
		p += b[i]
	elif b[i] < 0 and p > 0:
		p -= abs(b[i])
	elif b[i] < 0 and p <= 0:
		count += 1
print(count)


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


n = int(input())
l = list(map(int, input().split()))
c = 0
a = 0
for i in range(len(l)):
	if a == 0 and l[i] == -1:
		c = c + 1
	else:
		a = a + l[i]
print(c)


n = int(input())
arr = list(map(int, input().strip().split(' ')))
count = 0
s = 0
for i in arr:
	if i > 0:
		s += i
	if i < 0:
		if s > 0:
			s += i
		else:
			count += i
print(count * -1)


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


n = int(input(''))
s = input('')
x = s.split(' ')
i = 0
sum = 0
unsolved = 0
while i < n:
	if int(x[i]) < 0:
		if sum > 0:
			sum = sum - 1
		else:
			unsolved = unsolved + 1
	else:
		sum = sum + int(x[i])
	i = i + 1
print(unsolved)


n = int(input())
a = list(map(int, input().strip().split(' ')))
police = 0
crimesuntreated = 0
for i in a:
	if i > 0:
		police += i
	elif i == -1:
		if police > 0:
			police -= 1
		else:
			crimesuntreated += 1
print(crimesuntreated)


n = int(input())
a = list(map(int, input().split()))
vori = 0
police = 0
for i in range(n):
	if a[i] < 0:
		if police > 0:
			police = police + a[i]
		elif police <= 0:
			vori = vori + a[i]
	elif a[i] > 0:
		police = police + a[i]
print(abs(vori))


n = int(input())
(s, z) = (0, 0)
a = list(map(int, input().split()))
for i in a:
	if i > 0:
		s = s + i
	elif s > 0:
		s = s + i
	else:
		z += 1
print(z)


n = int(input())
check = [int(x) for x in input().split()]
sum = count = 0
for i in range(n):
	sum += check[i]
	if sum < 0:
		count += 1
		sum += 1
print(count)


inp = input()
inp1 = input().split()
l = []
for letter in inp1:
	l.append(int(letter))
police_officer = 0
crimes = 0
for num in l:
	if num == -1:
		if police_officer == 0:
			crimes += 1
		else:
			police_officer -= 1
	else:
		police_officer += num
print(crimes)


n = int(input())
a = list(map(int, input().split()))
c = 0
k = 0
for _ in range(len(a)):
	if a[_] >= 1:
		c += a[_]
	elif c + a[_] >= 0:
		c -= 1
	else:
		k += 1
print(k)


n = int(input())
l = list(map(int, input().split()))
suma = 0
ans = 0
for f in range(n):
	suma += l[f]
	if suma < 0:
		ans += 1
		suma = 0
print(ans)


n = int(input())
li = [int(x) for x in input().split()]
ponow = 0
cri = 0
for i in li:
	if i >= 1:
		ponow += i
	if i <= -1:
		if ponow + i >= 0:
			ponow += i
		else:
			cri -= ponow + i
			ponow = 0
print(cri)


d = input()
s = (int(i) for i in input().split())
z = 0
x = 0
for i in s:
	if i == -1:
		if z == 0:
			x += 1
		else:
			z -= 1
	else:
		z += i
print(x)


n = list(map(int, input().split()))
x = list(map(int, input().split()))

def solve(n, x):
	crimes = 0
	recruits = 0
	for i in x:
		if i == -1 and recruits == 0:
			crimes += 1
		elif i > 0:
			recruits += i
		else:
			recruits -= 1
	print(crimes)
solve(n, x)


casos = int(input())
datos = list(str(input()).split())
policiasTotales = 0
delitosTotales = 0
for j in range(len(datos)):
	datos[j] = int(datos[j])
for j in datos:
	if j < 0:
		if j * -1 <= policiasTotales:
			policiasTotales += j
		else:
			delitosTotales += j * -1 - policiasTotales
			policiasTotales = 0
	else:
		policiasTotales += j
print(delitosTotales)


n = int(input())
lis = list(map(int, input().split()))
police = 0
ctr = 0
for i in lis:
	if i == -1 and police == 0:
		ctr += 1
	elif i == -1 and police > 0:
		police -= 1
	else:
		police += i
print(ctr)


n = int(input())
my_list = list(map(int, input().split()))
neg_counter = 0
pos_counter = 0
for i in range(n):
	if my_list[i] == -1 and pos_counter == 0:
		neg_counter += 1
	elif my_list[i] != -1:
		pos_counter += my_list[i]
	else:
		pos_counter -= 1
print(neg_counter)


a = int(input())
l = list(map(int, input().split()))
ans = 0
sm = 0
for i in range(len(l)):
	if l[i] > 0:
		if sm < 0:
			ans += abs(sm)
			sm = 0
	sm += l[i]
	if i == len(l) - 1 and sm < 0:
		ans += abs(sm)
print(ans)


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


n = int(input())
c = list(map(int, input().split()))
l = uTreated = recruits = 0
for i in c:
	if i == -1:
		if recruits == 0:
			uTreated += 1
		else:
			recruits -= 1
	else:
		recruits += i
print(uTreated)


n = int(input())
crime_officer = [int(x) for x in input().split()]
cop_count = 0
crime_count = 0
for i in range(n):
	if crime_officer[i] < 0:
		crime_count += 1
		if cop_count > 0:
			cop_count -= 1
			crime_count -= 1
	else:
		cop_count += crime_officer[i]
print(crime_count)


n = int(input())
a = [int(x) for x in input().split()]
r = 0
count = 0
for i in a:
	if i == -1:
		if r == 0:
			count += 1
		else:
			r -= 1
	else:
		r += i
print(count)


import sys
n = int(input())
alist = list(map(int, sys.stdin.readline().split()))
ans = 0
s = 0
for i in alist:
	if i >= 0:
		s += i
	elif s + i >= 0:
		s += i
	else:
		ans += 1
print(ans)


n = int(input())
events = list(map(int, input().strip().split()))
recruits = 0
untreated = 0
for i in events:
	if i == -1:
		if recruits == 0:
			untreated += 1
		else:
			recruits -= 1
	else:
		recruits += i
print(untreated)


n = int(input())
a = list(map(int, input().strip().split()))[:n]
count = 0
temp_off = 0
for i in range(n):
	if a[i] == -1 and temp_off > 0:
		temp_off -= 1
	elif a[i] == -1 and temp_off == 0:
		count += 1
	elif a[i] > 0:
		temp_off += a[i]
print(count)


n = int(input())
p = list(map(int, input().split()))
sum = 0
un = 0
for item in p:
	if item > -1:
		sum += item
	elif item == -1:
		if sum > 0:
			sum -= 1
		elif sum == 0:
			un += 1
print(un)


t = int(input())
inp = list(map(int, input().split()))
staff = 0
un = 0
for i in range(len(inp)):
	if inp[i] < 0 and staff > 0:
		staff = staff - 1
	elif inp[i] < 0 and staff == 0:
		un += 1
	elif inp[i] > 0:
		staff = staff + inp[i]
print(un)


n = int(input())
events = list(map(int, input().split()))[:n]
officers = 0
untreated = 0
remained = 0
left = 0
for i in range(len(events)):
	if events[i] < 0:
		untreated = untreated + events[i]
	elif events[i] > 0:
		officers = officers + events[i]
	else:
		untreated = untreated + 0
		officers = officers + 0
	left = officers + untreated
	if left < 0:
		remained = remained + 1
		untreated = untreated + 1
print(remained)


input()
now = count = 0
for num in map(int, input().split()):
	now += num
	if now < 0:
		count += 1
		now = 0
print(count)


n = int(input())
arr = list(map(int, input().split()[:n]))
s = len(arr)
count = 0
p = 0
for i in range(s):
	if arr[i] > 0:
		count = count + arr[i]
	elif arr[i] == -1 and count > 0:
		count = count - 1
	elif arr[i] == -1 and count <= 0:
		p = p + 1
print(p)


import functools
n = int(input())
a = [int(x) for x in input().split()]
result = 0
max = 0
for v in a:
	result += v
	if result < max:
		max = result
print(abs(max))


n = int(input())
inp = list(map(int, input().split()))
officers = 0
result = 0
for i in range(0, n):
	if inp[i] > 0:
		officers = officers + inp[i]
	elif officers + inp[i] < 0:
		result = result + -1 * (officers + inp[i])
		officers = 0
	else:
		officers = officers + inp[i]
print(result)


a = int(input())
k = 0
t = 0
l = list(map(int, input().split()))
for i in range(len(l)):
	if l[i] > 0:
		k += l[i]
	elif k > 0:
		k -= 1
	else:
		t += 1
print(t)


n = int(input())
line = str(input()).split()
line = [int(it) for it in line]
value = 0
curr = 0
for i in range(n):
	if line[i] > 0:
		if curr < 0:
			value -= curr
			curr = line[i]
		else:
			curr += line[i]
	else:
		curr += line[i]
if curr < 0:
	value -= curr
print(value)


events = int(input())
crimes = list(map(int, input().split()))
untreated = 0
hired = 0
for i in range(events):
	currnetCrime = crimes[i]
	if currnetCrime == abs(currnetCrime):
		hired += currnetCrime
		continue
	if hired > 0 and currnetCrime != abs(currnetCrime):
		hired -= 1
		continue
	if hired == 0 and currnetCrime != abs(currnetCrime):
		untreated += 1
print(untreated)


n = int(input())
e = list(map(int, input().split()))
ans = 0
hire = 0
for ei in e:
	if ei > 0:
		hire += ei
	elif ei == -1:
		if hire >= 1:
			hire -= 1
		elif hire < 1:
			ans += 1
print(ans)


n = int(input())
ar = list(map(int, input().split()))
q = p = count = i = 0
while i < n:
	if ar[i] > 0:
		p = p + ar[i]
		i += 1
	else:
		count = p + ar[i]
		if count < 0:
			q += 1
		else:
			p -= 1
		i += 1
print(q)


noOfEvents = int(input())
All_crimes = list(map(int, input().split(' ')))
officers = 0
unsolved = 0
for i in All_crimes:
	crimes = 0
	if i >= 1:
		officers += i
	else:
		crimes += 1
		if officers >= crimes:
			officers = officers - 1
		else:
			unsolved += 1
print(unsolved)


def crimes(arr):
	avail = 0
	ans = 0
	for i in arr:
		if i == -1:
			if avail == 0:
				ans += 1
			else:
				avail -= 1
		else:
			avail += i
	return ans
int(input())
x = list(map(int, input().rstrip().split()))
print(crimes(x))


event = int(input())
description = list(map(int, input().split()))
d = len(description)
if d != event:
	print('Error')
x = 0
y = 0
for i in description:
	y += i
	if y < 0:
		x += i
		y = 0
print(abs(x))


a = int(input())
b = list(map(int, input().split()))
(police, crime) = (0, 0)
for x in range(a):
	if b[x] > 0:
		police += b[x]
		crime += 0
	elif b[x] < 0:
		if police + b[x] >= 0:
			police = police + b[x]
			crime += 0
		elif police + b[x] < 0:
			crime = crime - (police + b[x])
print(crime)


n = int(input())
arr = list(map(int, input().split()))
ans = 0
recruited_count = 0
for i in arr:
	if i == -1:
		if recruited_count > 0:
			recruited_count -= 1
		else:
			ans += 1
	else:
		recruited_count += i
print(ans)


from sys import stdin, stdout
input = stdin.readline
n = int(input())
a = list(map(int, input().split()))
ans = 0
man = 0
for i in range(n):
	if a[i] != -1:
		man += a[i]
	elif a[i] == -1 and man == 0:
		ans += 1
	else:
		man -= 1
stdout.write(str(ans))


n = int(input())
a = [int(x) for x in input().split()]
s = 0
for i in a[::-1]:
	s = min(0, s + i)
print(-s)


recruits = 0
crimes = 0
num_events = int(input())

def clean(events):
	new = events
	for i in range(1, len(events) + 1):
		if events[-i] < 0:
			return new
		new = new[:-1]
	return new
events = clean([int(x) for x in input().split(' ')])
for i in events:
	recruits += i
	if recruits < 0:
		recruits = 0
		crimes += 1
print(crimes)


events = int(input())
sequence = [int(i) for i in input().split(' ')]
available = 0
untreated = 0
for event in sequence:
	if event != -1:
		available += event
	elif available > 0:
		available -= 1
	else:
		untreated += 1
print(untreated)


(n, p, urc) = (int(input()), 0, 0)
for e in (int(x) for x in input().split()):
	p += e
	if p == -1:
		p = 0
		urc += 1
print(urc)


R = lambda : list(map(int, input().split()))
input()
a = R()
ans = cnt = 0
for i in a:
	if i == -1:
		if cnt:
			cnt -= 1
		else:
			ans += 1
	elif i != -1:
		cnt += i
print(ans)


n = int(input())
l = list(map(int, input().split()))[:n]
rec = fail = 0
for i in range(n):
	if l[i] > 0:
		rec += l[i]
	elif rec > 0:
		rec -= 1
	else:
		fail += 1
print(fail)


x = int(input())
lista = [int(x) for x in input().split()]
police_availabe = 0
crime_occurred = 0
for i in lista:
	if i > 0:
		police_availabe += i
	elif i < 0:
		if police_availabe - 1 < 0:
			police_availabe = 0
			crime_occurred += 1
		else:
			police_availabe -= 1
print(crime_occurred)


n = int(input())
l = [int(i) for i in input().split()]
c = 0
a = 0
z = 0
if set(l) == {-1}:
	print(n)
elif set(l) == {1}:
	print(0)
else:
	for i in range(n):
		if l[i] >= 1:
			c += l[i]
		elif c <= 0:
			z += 1
		else:
			c -= 1
	print(z)


a = input()
s = map(int, input().split())
officers = 0
crimes = 0
for i in s:
	if i > 0:
		officers += i
	elif officers == 0:
		crimes += 1
	else:
		officers -= 1
print(crimes)


import math
import sys
import heapq
from collections import deque, defaultdict
from itertools import permutations, combinations, combinations_with_replacement
import random
import os
mod = 10 ** 9 + 7
MAX = sys.maxsize
MIN = -sys.maxsize - 1

def isPrime(n):
	if n > 1:
		for i in range(2, n):
			if n % i == 0:
				return False
		else:
			return True
	else:
		return False

def isPanagram(s):
	alphabet = 'abcdefghijklmnopqrstuvwxyz'
	for char in alphabet:
		if char not in s.lower():
			return False
	return True

def isEqual(list1):
	if len(list1) < 0:
		res = True
	res = all((ele == list1[0] for ele in list1))
	if res:
		return True
	else:
		return False

def remove_duplicate(list1):
	final_list = []
	for i in list1:
		if i not in final_list:
			final_lis.append(i)
	return final_list

def solve():
	n = int(input())
	m = list(map(int, input().split()))
	count = 0
	s = 0
	for i in range(n):
		if m[i] > 0:
			s += m[i]
		elif s > 0:
			s -= 1
		else:
			count += 1
	return count
print(solve())


n = int(input())
a = list(map(int, input().split()))
officiers = 0
ans = 0
for e in a:
	if e == -1 and officiers == 0:
		ans += 1
	elif e == -1 and officiers > 0:
		officiers -= 1
	else:
		officiers += e
print(ans)


input()
y = [int(i) for i in input().split()]
(a, c) = (0, 0)
for i in y:
	a = a + i
	if a < 0:
		c += 1
		a = 0
print(c)


input_s = int(input())
input_l = input().split(' ')
no_p = 0
p = 0
for l in input_l:
	num_l = int(l)
	p += num_l
	if p <= 0:
		no_p += -p
		p = 0
print(no_p)


n = int(input())
a = 0
b = 0
x = map(int, input().split())
for i in x:
	if a == 0:
		if i > 0:
			a += i
		elif i < 0:
			a = 0
			b += i
	elif a > 0:
		a += i
print(abs(b))


n = int(input())
list1 = list(map(int, input().split()))
sum1 = 0
count = 0
for i in list1:
	sum1 += i
	if sum1 < 0:
		count += 1
		sum1 = 0
print(count)


n = int(input())
orders = [int(i) for i in input().split()]
untreated = 0
officer = 0
for event in orders:
	if event == -1 and officer != 0:
		officer -= 1
	elif event == -1 and officer == 0:
		untreated += 1
	else:
		officer += event
print(untreated)


__author__ = 'Lipen'

def main():
	n = int(input())
	a = list(map(int, input().split()))
	now = 0
	answer = 0
	for x in a:
		if x == -1:
			if now > 0:
				now -= 1
			else:
				answer += 1
		else:
			now += x
	print(answer)
main()


n = int(input())
officers = 0
crimes_untreated = 0
for x in input().split():
	x = int(x)
	if x > 0:
		officers += x
	else:
		officers += x
		if officers < 0:
			crimes_untreated += -officers
			officers = 0
print(crimes_untreated)


import math
t = int(input())
a = list(map(int, input().split()))
count = 0
s = 0
zz = 5
z = []
for x in a:
	if x > 0:
		if zz == 1:
			z.append(s)
			s = x
			zz = 0
		else:
			zz = 0
			s += x
	elif zz == 0:
		z.append(s)
		s = x
		zz = 1
	else:
		s += x
		zz = 1
z.append(s)
count = 0
s = 0
for x in a:
	if x >= 0:
		s += x
	else:
		s += x
		if s >= 0:
			continue
		else:
			count += math.fabs(x)
			s = 0
print(int(count))


n = int(input())
a = input().split()
p = 0
c = 0
for i in range(n):
	if int(a[i]) == -1:
		if p == 0:
			c += 1
		else:
			p -= 1
	else:
		p += int(a[i])
print(c)


n = int(input())
a = list(map(int, input().split()))
pol = 0
cri = 0
for i in range(0, n):
	t = a[i]
	if t == -1 and pol == 0:
		cri += 1
	elif t == -1 and pol > 0:
		pol -= 1
	elif t > -1:
		pol += t
print(cri)


n = int(input())
lst = list(map(int, input().split()))
u = 0
police = 0
crime = 0
for i in lst:
	if i == -1:
		if police == 0:
			crime += 1
		else:
			police -= 1
	else:
		police += i
print(crime)


(n, r, c, cc) = (int(input()), 0, 0, 0)
for nn in list(map(int, input().split())):
	if c >= cc and c > 0 and (nn == -1):
		c -= 1
	elif nn == -1:
		r += 1
		cc = 0
	else:
		c += nn
print(r)


def func(n):
	k = list(map(int, input().split()))
	counter = 0
	recruited = 0
	for i in k:
		if recruited + i < 0:
			counter += 1
		else:
			recruited += i
	print(counter)
n = int(input())
func(n)


input()
l = 0
s = 0
for n in map(int, input().split()):
	l += n
	if l < 0:
		s -= l
		l = 0
print(s)


n = int(input())
x = [int(i) for i in input().split()]
count = 0
police = 0
for i in range(len(x)):
	if x[i] == -1 and police >= 1 and (police <= 10):
		police = police - 1
	elif x[i] == -1 and police <= 10:
		count = count + 1
	else:
		police = police + x[i]
print(count)


n = int(input())
e = map(int, input().split())
crimes = 0
positive = 0
for event in e:
	if positive or event > 0:
		positive += event
	else:
		crimes += 1
print(crimes)


a = int(input())
b = [int(s) for s in input().split()]
s1 = 0
s2 = 0
kek = 0
for i in b:
	if i < 0:
		if s2 == 0:
			kek += 1
		else:
			s2 -= 1
	else:
		s2 += i
print(kek)


def solve():
	n = int(input())
	ans = 0
	mas = [int(s) for s in input().split()]
	k = 0
	for i in range(n):
		if mas[i] > -1:
			k += mas[i]
		elif k == 0:
			ans += 1
		else:
			k -= 1
	print(ans)
solve()


n = int(input())
timeline = map(int, input().split())
polices = 0
untreated = 0
for event in timeline:
	if event > 0:
		polices += event
	elif polices > 0:
		polices -= 1
	else:
		untreated += 1
print(untreated)


t = int(input())
l = list(map(int, input().split()))
(sm, cnt) = (0, 0)
for i in range(t):
	if l[i] > 0:
		sm += l[i]
	elif sm > 0:
		sm -= 1
	else:
		cnt += 1
print(cnt)


import sys
import math
import os
t = int(input())
count = 0
countCriminal = 0
data = list(map(int, input().split()))
for k in range(len(data)):
	if data[k] > 0:
		count += int(data[k])
	elif count > 0:
		count -= 1
	else:
		countCriminal += 1
print(countCriminal)


n = int(input())
list = [int(i) for i in input().split()]
p = 0
c = 0
cnt = 0
for i in range(n):
	if list[i] == -1:
		if p == 0:
			cnt += 1
		else:
			p -= 1
	else:
		p += list[i]
print(cnt)


n = int(input())
ar = list(map(int, input().split()))
(crime, rec) = (0, 0)
for i in ar:
	if i == -1:
		if rec == 0:
			crime += 1
		else:
			rec -= 1
	else:
		rec += i
print(crime)


def crime(values):
	count = 0
	c = 0
	p = 0
	for i in range(len(values)):
		if values[i] > 0:
			p = p + values[i]
		elif values[i] == -1:
			if p > 0:
				p = p - 1
			else:
				count = count + 1
	return count
n = int(input())
values = list(map(int, input().split()))
print(crime(values))


n = int(input())
a = list(map(int, input().split()))
officers_available = 0
untreated_crimes = 0
for num in a:
	if num == -1 and officers_available == 0:
		untreated_crimes += 1
	elif num == -1 and officers_available > 0:
		officers_available -= 1
	else:
		officers_available += num
print(untreated_crimes)


n = int(input())
l = list(map(int, input().split()))
tp = 0
c = 0
for i in l:
	if tp == 0 and i < 0:
		c += 1
	elif i > 0:
		tp += i
	elif i < 0:
		tp += i
print(c)


n = int(input())
arr = [int(x) for x in input().split(' ')]
curr_cops = 0
crimes = 0
for a in arr:
	if a > 0:
		curr_cops += a
	if a == -1 and curr_cops == 0:
		crimes += 1
	if curr_cops > 0 and a == -1:
		curr_cops -= 1
print(crimes)


n = int(input())
a = list(map(int, input('').split()))
crime = 0
cops = 0
for i in range(len(a)):
	bbbb = a[i]
	if a[i] < 0 and cops == 0:
		crime += abs(a[i])
	elif a[i] < 0 and cops > 0 and (crime > 0):
		cops -= abs(a[i])
	elif a[i] < 0 and cops > 0:
		cops -= abs(a[i])
	elif a[i] > 0:
		cops += abs(a[i])
print(crime)


n = int(input())
data = input()
data = data.split()
num_cops = 0
num_untreated = 0
for i in range(0, n):
	j = int(data[i])
	if j == -1:
		if num_cops > 0:
			num_cops -= 1
		else:
			num_untreated += 1
	else:
		num_cops += j
print(num_untreated)


a = int(input())
n = [int(x) for x in input().split()]
sum = 0
count = 0
for i in n:
	if i > 0:
		sum = sum + i
	elif sum > 0:
		sum = sum - 1
	else:
		count = count + 1
print(count)


input()
x = list(map(int, input().split()))
count = 0
s = 0
for i in x:
	if str(i) == '-1':
		if count > 0:
			count = count - 1
		else:
			s += 1
	else:
		count += i
print(s)


c = int(input())
h = list(map(int, input().split()))
p_count = 0
out = 0
for i in h:
	if i == -1:
		if p_count == 0:
			out += 1
		else:
			p_count -= 1
	if 1 <= i <= 10:
		p_count += i
print(out)


n = int(input())
a = input()
a = [int(x) for x in a.split()]
(kol1, kol2) = (1, 0)
for i in range(n):
	if a[i] is -1:
		kol1 -= 1
	else:
		kol1 += a[i]
		continue
	if kol1 == 0:
		kol2 += 1
		kol1 = 1
print(kol2)


n = int(input())
l = list(map(int, input().split()))
pos = 0
t = 0
for i in l:
	if i < 0:
		if i + pos < 0:
			t += 1
		else:
			pos = pos + i
	else:
		pos += i
print(t)


need_log = False

def log(*s):
	if need_log:
		print(*s)
n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
for k in a:
	if k == -1:
		if y == 0:
			x += 1
		else:
			y -= 1
	else:
		y += k
print(x)


a = input()
x = list(map(int, input().split()))
h = u = 0
for e in x:
	if e > 0:
		h += e
		continue
	if e < 0 and h > 0:
		h -= 1
		continue
	if e < 0 and h < 1:
		u += 1
print(u)


input()
a = list(map(int, input().split()))
(p, s) = (0, 0)
for x in a:
	if x == -1:
		if p == 0:
			s = s + 1
		else:
			p = p - 1
	else:
		p += x
print(s)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_strList_from_str = lambda : list(sys.stdin.readline().strip())
get_int = lambda : int(sys.stdin.readline().strip())
pt = lambda x: sys.stdout.write(str(x))
n = get_int()
hiring_seq = get_list()
policeman = 0
unnoticed = 0
for i in range(n):
	if hiring_seq[i] == -1:
		if policeman > 0:
			policeman -= 1
		else:
			unnoticed += 1
	else:
		policeman += hiring_seq[i]
print(unnoticed)


t = int(input())
lst = list(map(int, input().split()))
(sum1, count) = (0, 0)
for i in range(t):
	if lst[i] > 0:
		sum1 += lst[i]
	elif sum1 > 0:
		sum1 -= 1
	else:
		count += 1
print(count)


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 solve(events):
	untreatedCrimes = 0
	policeAvailable = 0
	for event in events:
		if event == -1:
			if policeAvailable > 0:
				policeAvailable -= 1
			else:
				untreatedCrimes += 1
		else:
			policeAvailable += event
	return untreatedCrimes
n = inp()
events = inlt()
print(solve(events))


a = int(input())
b = list(map(int, input().split(' ')))
count = 0
cases = 0
for i in b:
	if i != -1:
		count = count + i
	elif count == 0:
		cases = cases + 1
	else:
		count = count - 1
print(cases)


n = int(input())
a = list(map(int, input().split()))
sum = 0
set = 0
for i in a:
	if i == -1 and sum == 0:
		set += 1
	elif i > 0:
		sum += i
	elif i == -1 and sum > 0:
		sum -= 1
print(set)


k = input()
x = [int(i) for i in input().split()]
police = 0
untreated = 0
for i in x:
	if i < 0:
		if police + i < 0:
			untreated += 1
		else:
			police += i
	if i > 0:
		police += i
print(untreated)


(cnt, rec) = (0, 0)
n = int(input())
ar = list(map(int, input().split()))
for i in ar:
	if rec == 0 and i == -1:
		cnt += 1
	elif rec > 0 and i == -1:
		rec -= 1
	if i > 0:
		rec += i
print(cnt)


n = int(input())
stack = []
res = 0
arr = input()
recr = list(map(int, arr.split(' ')))
for i in range(0, len(recr)):
	h = recr[i]
	if h != -1:
		for i in range(1, h + 1):
			stack.append(1)
	elif len(stack) == 0:
		res += 1
	else:
		stack.pop()
print(res)


n = int(input())
elist = list(map(int, input().split()))
remain_r = 0
count = 0
for i in range(n):
	if elist[i] > 0:
		remain_r += elist[i]
	elif elist[i] < 0:
		remain_r += elist[i]
		if remain_r < 0:
			count += 1
			remain_r = 0
print(count)


n = int(input())
inpt = list(map(int, input().split(' ')))[:n]
count = 0
policeman = 0
for i in inpt:
	if i > 0:
		policeman += i
	elif policeman + i < 0:
		count += 1
	else:
		policeman -= 1
print(count)


n = int(input())
text = input()
events = text.split()
police_officers = 0
untreated = 0
for i in range(0, n):
	if events[i] == '-1':
		if police_officers > 0:
			police_officers -= 1
		else:
			untreated += 1
	else:
		events[i] = int(events[i])
		police_officers += events[i]
print(untreated)


n = int(input())
x = [int(i) for i in input().split()]
count = 0
free = 0
for i in range(n):
	if x[i] == -1 and free == 0:
		count += 1
	elif x[i] > 0:
		free += x[i]
	elif x[i] == -1 and free != 0:
		free -= 1
print(count)


def untreated(n, events):
	crimes = 0
	for event in range(n):
		if event == n - 1:
			if events[event] < 0:
				return crimes + 1
			return crimes
		if events[event] < 0:
			crimes += 1
		else:
			events[event + 1] += events[event]
	return crimes
print(untreated(int(input()), list(map(int, input().split()))))


n = int(input())
c = list(map(int, input().split(' ')))
foo = 0
count = 0
for i in range(n):
	if foo == 0 and c[i] == -1:
		count += 1
	elif foo > 0 and c[i] == -1:
		foo -= 1
	else:
		foo += c[i]
print(count)


n = int(input(''))
crims_polics = [int(x) for x in input('').split(' ')]
police = 0
solved_crime = 0
unsolved_crimes = 0
for i in range(n):
	if crims_polics[i] > 0:
		police += crims_polics[i]
	elif crims_polics[i] == -1:
		if police > 0:
			police -= 1
			solved_crime += 1
		else:
			unsolved_crimes += 1
print(unsolved_crimes)


n = int(input())
li = list(map(int, input().split()))
(m, z) = (0, 0)
for i in li:
	if i > 0:
		z = z + i
	elif z > 0 and i < 0:
		z = z + i
	elif z == 0:
		m += abs(i)
print(m)


n = int(input())
A = list(map(int, input().split()))
cops = ans = 0
for val in A:
	if val < 0:
		val = abs(val)
		if cops >= val:
			cops -= val
			val = 0
		else:
			val -= cops
			cops = 0
		ans += val
	else:
		cops += val
print(ans)


n = int(input())
crims = list(map(int, input().split()))
ut = 0
man_p = 0
for c in crims:
	if c < 0:
		if man_p > 0:
			man_p -= 1
		else:
			ut += 1
	else:
		man_p += c
print(ut)


n = int(input())
e = [int(x) for x in input().split()]
c = 0
u = 0
for i in range(n):
	c += e[i]
	if c < 0:
		u += 1
		c = 0
print(u)


events = int(input())
crimes = 0
available_police = 0
occurences = list(map(int, input().split(' ')))
for i in occurences:
	if i == -1 and available_police > 0:
		available_police -= 1
	elif i == -1 and available_police == 0:
		crimes += 1
	elif i > 0:
		available_police += i
print(crimes)


def answer():
	n = int(input())
	a = input().split()
	i = 0
	ans = 0
	cops = 0
	while i < len(a):
		if a[i] == '-1':
			if not cops:
				ans += 1
			else:
				cops -= 1
		else:
			cops += int(a[i])
		i += 1
	return ans
print(answer())


s = 0
k = 0
n = int(input())
l = list(map(int, input().split()))
for x in range(n):
	if l[x] == -1 and s == 0:
		k += 1
	else:
		s += l[x]
print(k)


n = int(input())
l = list(map(int, input().split()))
(result, police) = (0, 0)
for i in range(0, n):
	if l[i] == -1 and police == 0:
		result += 1
	elif l[i] == -1 and police != 0:
		police -= 1
	else:
		police += l[i]
print(result)


cases = int(input())
crimes = [int(s) for s in input().split()]
free_polices = 0
untreated = 0
for c in crimes:
	if c != -1:
		free_polices += c
	elif free_polices == 0:
		untreated += 1
	else:
		free_polices -= 1
print(untreated)


n = int(input())
arr = [int(x) for x in input().split()]
(sum, off) = (0, 0)
for x in arr:
	if x == -1:
		if off == 0:
			sum += 1
		else:
			off -= 1
	else:
		off += x
print(sum)


n = int(input())
line = [int(i) for i in input().split()]
untreat = 0
police = 0
for i in range(n):
	if line[i] > 0:
		police += line[i]
	elif police < 1:
		untreat += 1
	elif police >= 1:
		police -= 1
print(untreat)


import operator as op
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import reduce
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

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

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

def instr():
	s = input()
	return list(s[:len(s)])

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

def def_value():
	return 0
n = inp()
a = inlist()
p = un = 0
for i in a:
	if i > 0:
		p += i
	elif p > 0:
		p -= 1
	else:
		un += 1
print(un)


n = int(input())
t = 0
police = 0
s = [int(i) for i in input().split()]
for i in range(n):
	if s[i] == -1:
		if police > 0:
			police = police - 1
		else:
			t = t + 1
	else:
		police = police + s[i]
print(t)


input()
x = 0
cr = 0
a = input().split()
for i in a:
	if i != '-1':
		x += int(i)
	elif x == 0:
		cr += 1
	else:
		x -= 1
print(cr)


a = int(input())
b = [int(x) for x in input().split()]
c = 0
count = 0
i = 0
while i < a:
	c = c + b[i]
	if c < 0:
		count = count + 1
		c = c - 1
		if c < 0:
			c = 0
	i = i + 1
print(count)


_ = int(input())
tot = 0
pol = 0
string = map(int, input().split())
for i in string:
	pol += i
	if pol < 0:
		tot -= pol
		pol = 0
print(tot)


n = int(input())
m = list(map(int, input().split()))
cc = 0
cr = 0
for i in range(n):
	if m[i] > 0:
		cr += m[i]
	if m[i] < 0:
		if cr > 0:
			cr -= 1
		else:
			cc += abs(m[i])
print(cc)


t = int(input())
l = list(map(int, input().strip().split()))
a = 0
for i in range(t):
	if l[i] > 0:
		a = a + l[i]
	elif a > 0:
		l[i] = l[i] + 1
		a = a - 1
print(l.count(-1))


n = int(input())
ar = list(map(int, input().split()))
r = 0
t = 0
for i in ar:
	r += i
	t += r < 0
	r = max(0, r)
print(t)


(n, a) = (int(input()), list(map(int, input().split())))
(z, c) = (0, 0)
for i in a:
	if i > 0:
		c += i
		continue
	elif (i < 0) & (c > 0):
		c -= 1
		continue
	elif i < 0:
		z += 1
print(z)


n = int(input())
police = list(map(int, input().split()))
result = 0
count = 0
for i in police:
	if result == 0 and i < 0:
		count += 1
	else:
		result += i
print(count)


k = int(input())
a = [int(x) for x in input().split(' ')]
sum = 0
avail = 0
for x in a:
	if x > 0:
		avail += x
	elif avail == 0:
		sum += 1
	else:
		avail -= 1
print(sum)


n = int(input())
events = [int(x) for x in input().split()]
(officer, untreated) = (0, 0)
for event in events:
	if event > 0:
		officer += event
	elif officer > 0:
		officer -= 1
	else:
		untreated += 1
print(untreated)


n = int(input())
a = [int(i) for i in input().split()]
cops = 0
miss = 0
for i in a:
	if i == -1:
		if cops < 1:
			miss += 1
		else:
			cops -= 1
	else:
		cops += i
print(miss)


n = int(input())
events = list(map(int, input().split()))
policemens = 0
usolved_crimes = 0
for i in range(n):
	if events[i] > 0:
		policemens += events[i]
	if events[i] < 0:
		if abs(events[i]) > policemens:
			usolved_crimes += abs(events[i]) - policemens
		else:
			policemens -= abs(events[i])
print(usolved_crimes)


n = int(input())
a = [int(k) for k in input().split()]
p = 0
val = 0
for i in range(n):
	if a[i] != -1:
		p += a[i]
	elif p > 0:
		p -= 1
	else:
		val += 1
print(val)


n = int(input())
inp = input().split()
arr = list()
for i in range(len(inp)):
	arr.append(int(inp[i]))
p = 0
crime = 0
for i in range(len(arr)):
	if arr[i] == -1:
		if p <= 0:
			crime += 1
		else:
			p = p - 1
	else:
		p = p + arr[i]
print(crime)


input()
s = list(map(int, input().split()))
cnt = 0
flag = 0
for i in s:
	if i is -1:
		if flag == 0:
			cnt += 1
		else:
			flag -= 1
	elif i != -1:
		flag += int(i)
print(cnt)


n = int(input())
events = [int(i) for i in input().split()]
recruits = 0
crime = 0
i = 0
while i < len(events):
	recruits += events[i]
	if recruits < 0:
		crime += 1
		recruits = 0
	i += 1
print('{}'.format(crime))


n = int(input())
l = []
ans = h = 0
l = list(map(int, input().split()))
for el in l:
	if el > 0:
		h += el
		continue
	if el < 0 and h > 0:
		h -= 1
		continue
	if el < 0:
		ans += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
rez = 0
otv = 0
for i in a:
	rez += i
	otv = min(otv, rez)
print(abs(otv))


cases = int(input())
no = 0
sum = 0
str1 = input()
li = str1.split()
for i in range(0, cases):
	if int(li[i]) > 0:
		sum += int(li[i])
	elif sum > 0:
		sum = sum - 1
	else:
		no = no + 1
print(no)


t = int(input())
lst = list(map(int, input().split()))
p = 0
q = 0
for t in range(t):
	if p > 0:
		if lst[t] == -1:
			p -= 1
		else:
			p += lst[t]
	elif lst[t] == -1:
		q += 1
	else:
		p += lst[t]
print(q)


n = int(input())
nums = [int(i) for i in input().split()]
crimes = 0
n_police = 0
for num in nums:
	if num == -1 and n_police == 0:
		crimes += 1
	elif num == -1 and n_police > 0:
		n_police -= 1
	else:
		n_police += num
print(crimes)


n = int(input())
police = 0
crimes = 0
lis = [int(x) for x in input().split()]
for x in lis:
	if x > 0:
		police += x
	elif police:
		police -= 1
	else:
		crimes += 1
print(abs(crimes))


n = int(input())
crime = list(map(int, input().split()))
sum = 0
ut = 0
for c in crime:
	if c > 0:
		sum += c
	elif sum == 0:
		ut += 1
	else:
		sum -= 1
print(ut)


a = int(input())
total = 0
crim = 0
no = 0
b = input()
separador = ' '
l = []
for i in b.split(separador):
	l.append(int(i))
for i in range(0, a):
	crim = 0
	if l[i] > 0:
		total += l[i]
	if l[i] < 0:
		crim -= l[i]
	if crim > total:
		no += crim - total
		total = 0
	if total >= crim:
		total -= crim
print(no)


n = int(input())
l = list(map(int, input().split()))
crimes = 0
manpower = 0
for i in l:
	if i >= 0:
		manpower += i
	elif manpower >= 1:
		manpower -= 1
	else:
		crimes += 1
print(crimes)


n = int(input())
pol = list(map(int, input().split()))
k = 0
p = 0
for i in pol:
	if i > 0:
		p += i
	elif i == -1:
		if p == 0:
			k += 1
		elif p > 0:
			p -= 1
print(k)


n = int(input())
ls = list(map(int, input().split()))
res = 0
for i in range(n):
	if ls[i] != -1:
		break
	else:
		res += 1
else:
	print(res)
	exit()
index = i
cnt = 0
for i in range(index, n):
	cnt += ls[i]
	if cnt < 0:
		res += 1
	cnt = max(0, cnt)
print(res)


s = int(input())
c = 0
crimes = 0
l = [int(x) for x in input().split()]
for i in l:
	if i != -1:
		c += i
	elif c == 0:
		crimes += 1
	else:
		c -= 1
print(crimes)


input()
c = list(map(int, input().split()))
tratados = 0
crimes = 0
for x in c:
	if x > 0:
		tratados += x
	elif tratados == 0:
		crimes += 1
	else:
		tratados -= 1
print(crimes)


total_input = int(input())
inputs = list(map(int, input().split()))
(recuit, crime, untreat) = (0, 0, 0)
for i in inputs:
	if i == -1:
		crime += 1
		if recuit > 0:
			recuit -= 1
		else:
			untreat += 1
	else:
		recuit += i
print(untreat)


n = int(input())
sums = 0
cnt = 0
m = list(map(int, input().split()))
for i in m:
	sums += i
	if sums < 0:
		cnt += 1
		sums = 0
print(cnt)


n = int(input())
happens = map(int, input().split())
police = 0
crime = 0
for i in happens:
	if i == -1:
		crime += 1
		if police > 0:
			crime -= 1
			police -= 1
	elif 0 < i <= 10:
		police += i
print(crime)


n = int(input())
m = list(map(int, input().split()))
crime = 0
police = 0
i = 0
while i < n:
	if m[i] > 0:
		police += m[i]
	elif police:
		police += m[i]
	else:
		crime += 1
	i += 1
print(crime)


n = int(input().strip())
events = list(map(int, input().strip().split()))
policeman = 0
crime = 0
for eve in events:
	if eve == -1:
		crime += 1
		if policeman > 0:
			policeman -= 1
			crime -= 1
	else:
		policeman += eve
print(crime)


n = int(input())
x = list(map(int, input().split()))
re = 0
c = 0
for i in x:
	if i == -1 and re == 0:
		c = c + 1
	elif re > 0 and i == -1:
		re = re - 1
	if i > 0:
		re = re + i
print(c)


n = input()
lst = [int(i) for i in input().split()]
dil = 0
police = 0
for i in lst:
	if i == -1:
		if police == 0:
			dil += 1
		else:
			police -= 1
	else:
		police += i
print(dil)


a = int(input())
ls = [int(item) for item in input().split(' ')]
officers = 0
cout = 0
for x in ls:
	if x == -1:
		if officers == 0:
			cout += 1
		else:
			officers -= 1
	else:
		officers += x
print(cout)


no = int(input())
a = input().split()
for e in range(len(a)):
	a[e] = int(a[e])
ans = 0
temp = 0
for each in a:
	temp += each
	if temp < 0:
		ans += 1
		temp = 0
print(ans)


def crime(lista):
	police = 0
	crimes = 0
	for i in lista:
		if i >= 1:
			police += i
		elif i == -1:
			if police > 0:
				police -= 1
			else:
				crimes += 1
	return crimes
_ = input()
lista = list(map(int, input().rstrip().split()))
print(crime(lista))


n = int(input())
events = map(int, input().split())
policeman_count = 0
crime_count = 0
for event in events:
	if event == -1:
		if policeman_count > 0:
			policeman_count -= 1
		else:
			crime_count += 1
	elif event > 0:
		policeman_count += event
print(crime_count)


n = int(input())
A = [*map(int, input().split())]
rec = 0
cri = 0
for a in A:
	rec += a
	if rec < 0:
		cri += -rec
		rec = 0
print(cri)


input()
np = 0
res = 0
for v in map(int, input().split()):
	if v > 0:
		np += v
	else:
		v = -v
		if np >= v:
			np -= v
		else:
			np = 0
			res += v - np
print(res)


n = input()
recruits = 0
untreated = 0
for event in [int(x) for x in input().split()]:
	if event == -1:
		if recruits == 0:
			untreated += 1
		else:
			recruits -= 1
	elif event > 10:
		recruits += 10
	else:
		recruits += event
print(untreated)


_ = input()
numbers = map(int, input().split())
(positive, negative) = (0, 0)
for n in numbers:
	if n > 0:
		positive += n
	elif positive > 0:
		positive -= 1
	else:
		negative -= 1
print(abs(negative))


n = int(input())
li = [int(x) for x in input().split()]
officers = 0
crimes = 0
for i in li:
	if i == -1 and officers == 0:
		crimes += 1
	else:
		officers += i
print(crimes)


numberOfEvents = int(input())
events = [int(i) for i in input().split(' ')]
policeOfficers = 0
crimes = 0
for (i, event) in enumerate(events):
	if event > 0:
		policeOfficers = policeOfficers + event
	elif policeOfficers == 0:
		crimes = crimes + 1
	else:
		policeOfficers = policeOfficers - 1
print(crimes)


x = int(input())
sabt = 0
e = 0
for x in map(int, input().split()):
	if x == -1:
		if sabt == 0:
			e += 1
		else:
			sabt -= 1
	else:
		sabt += x
print(e)


n = int(input())
inci = list(map(int, input().split()))
police = 0
crime = 0
for i in inci:
	if i > 0:
		police += i
	elif police == 0 and i < 0:
		crime += 1
	elif police != 0 and i < 0:
		police += i
print(crime)


n = int(input())
data = [int(i) for i in input().split()]
free = 0
cnt = 0
for x in data:
	if x == -1:
		if free > 0:
			free -= 1
		else:
			cnt += 1
	else:
		free += x
print(cnt)


n = int(input())
mang = [int(nhap) for nhap in input().split()]
nums = 0
untreated = 0
for i in mang:
	if i > 0:
		nums += i
	elif nums == 0:
		untreated += 1
	elif nums > 0:
		nums = nums - 1
print(untreated)


events = int(input())
what_events = []
what_events = input().split()
what_events = [int(a) for a in what_events]
untreated = 0
police_force = 0
for event in what_events:
	if event == -1 and police_force == 0:
		untreated = untreated + 1
	elif event == -1 and police_force > 0:
		police_force = police_force - 1
	elif event != -1:
		police_force = police_force + event
print(untreated)


n = int(input())
ll = list(map(int, input().split()))
(hired, c) = (0, 0)
for i in ll:
	if i > 0:
		hired += i
	elif i == -1 and hired != 0:
		hired -= 1
	else:
		c += 1
print(c)


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
ans = 0
police = 0
N = int(input())
A = [int(x) for x in input().split()]
for v in A:
	police += v
	if police < 0:
		police = max(police, 0)
		ans += 1
print(ans)


input()
a = map(int, input().split())
policemen = 0
crimes = 0
for e in a:
	policemen += e
	if policemen < 0:
		crimes += 1
		policemen = 0
print(crimes)


size = int(input())
count = 0
tem = 0
ls = list(map(int, input().split()))
for i in range(size):
	if tem == 0:
		if ls[i] == -1:
			count += 1
		else:
			tem = ls[i]
	else:
		tem += ls[i]
print(count)


n = int(input())
L = list(map(int, input().split()))
c = a = 0
for i in L:
	if i > 0:
		c = c + i
	elif c > 0:
		c = c - 1
	else:
		a = a + 1
print(a)


n = int(input())
events = input().split(' ')
(polishens, kraym) = (0, 0)
for i in events:
	if i == '-1':
		if polishens > 0:
			polishens -= 1
		else:
			kraym += 1
	else:
		polishens += int(i)
print(kraym)


n = int(input())
a = input().split()
x = 0
y = 0
for i in range(n):
	a[i] = int(a[i])
	if a[i] < 0:
		if x == 0:
			y -= a[i]
		elif x - a[i] < 0:
			y += a[i] - x
			x = 0
		else:
			x += a[i]
	else:
		x += a[i]
print(y)


n = int(input())
s = input().split()
u = 0
r = 0
for i in range(len(s)):
	k = int(s[i])
	if k < 0 and r <= 0:
		u = u + abs(k)
	if k < 0 and r > 0:
		if abs(k) > r:
			u = u + abs(k) - r
		else:
			r = r - abs(k)
	if k > 0:
		r = r + k
print(abs(u))


n = int(input())
a = 0
b = 0
t = 0
L = [int(x) for x in input().split()]
for i in L:
	if i > 0 and t:
		a = 0
	a += i
	if a < 0:
		b += 1
		t = 1
	else:
		t = 0
print(b)


n = int(input())
a = list(map(int, input().split()))
p = 0
cnt = 0
for i in a:
	if i == -1:
		if p > 0:
			p -= 1
		else:
			cnt += 1
	else:
		p += i
print(cnt)


import math
import sys
import re
n = int(input())
a = list(map(int, input().rstrip().split()))
minuscnt = 0
pluscnt = 0
for i in a:
	if pluscnt == 0 and i < 0:
		minuscnt = minuscnt + 1
	else:
		pluscnt = pluscnt + i
print(minuscnt)


events = int(input())
crime = list(map(int, input().split()))
officers = 0
count = 0
for i in range(events):
	if crime[i] < 0:
		if officers == 0:
			count += 1
		else:
			officers -= 1
	else:
		officers += crime[i]
print(count)


n = input()
n = int(n)
a = [int(x) for x in input().split()]
police = 0
untreated = 0
for i in a:
	if i > 0:
		police = police + i
	elif police == 0:
		untreated = untreated + 1
	else:
		police = police + i
print(untreated)


event_count = int(input(''))
event_type = input('')
lst = list()
for i in event_type.split():
	i = int(i)
	lst.append(i)
untreated_crimes = 0
officers = 0
for num in lst:
	if num > 0:
		officers += num
	elif num < 0:
		if officers == 0:
			untreated_crimes += 1
		elif officers > 0:
			officers -= 1
print(untreated_crimes)


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


n = int(input())
v = [int(x) for x in input().split()]
c = 0
su = 0
for i in v:
	if i == -1 and su <= 0:
		c += 1
	else:
		su += i
print(c)


n = int(input())
l = [int(i) for i in input().split()]
p = []
j = 0
for i in l:
	if (p == []) & (i == -1):
		j += 1
	elif (i == -1) & (p != []):
		p.pop()
	else:
		for k in range(i):
			p.append(1)
print(j)


def crimesAndCops(list):
	availableCops = 0
	crimesLeft = 0
	for i in list:
		if int(i) == -1:
			if availableCops == 0:
				crimesLeft += 1
			else:
				availableCops -= 1
		if int(i) > 0:
			availableCops += int(i)
	return crimesLeft
num = int(input())
listOfInputs = input().split()
print(crimesAndCops(listOfInputs))


number = input('')
events = [int(i) for i in input('').split(' ')]
recruits = 0
crimes = 0
for i in events:
	if i != -1:
		recruits += i
	elif recruits > 0:
		recruits -= 1
	else:
		crimes += 1
print(crimes)


n = int(input())
a = input().split()
a = [int(i) for i in a]
l = 0
k = 0
for i in a:
	if i == -1:
		if l < 1:
			k += 1
		else:
			l -= 1
	else:
		l += i
print(k)


sum = 0
crime = 0
n = int(input())
x = []
x = input().split()
for i in range(n):
	x[i] = int(x[i])
i = 0
while i < n:
	sum = x[i]
	t = sum
	if sum < 0:
		crime += 1
		sum = 0
	elif sum > 0:
		i += 1
		while i < n and sum != 0:
			sum += x[i]
			i += 1
	if t > 0:
		continue
	i += 1
print(crime)


def main(lista):
	force = 0
	mal = 0
	for i in lista:
		if i < 0:
			if force >= abs(i):
				force -= abs(i)
			else:
				mal += abs(i)
		elif i > 0:
			force += i
	print(mal)
n = int(input())
lista = list(map(int, input().rstrip().split()))
main(lista)


n = int(input())
p = 0
x = 0
inp = tuple(map(int, input().split()))
for i in inp:
	if i > 0:
		if p >= 0:
			p += i
		else:
			p = i
	else:
		p += i
	if p < 0:
		x += 1
print(x)


import sys
input()
e = [int(i) for i in input().split()]
result = 0
police = 0
for i in e:
	if i > 0:
		police += i
	elif i < 0 and police >= abs(i):
		police += i
	else:
		result -= i
print(result)


n = int(input())
l = list(map(int, input().split()))
crimes = 0
police = 0
res = 0
for d in l:
	if d == -1:
		if police > 0:
			police -= 1
		else:
			res += 1
	else:
		police += d
print(res)


n = int(input())
ara = list(map(int, input().split()))
cnt = 0
police = 0
for i in range(n):
	if ara[i] == -1:
		if police:
			police -= 1
		else:
			cnt += 1
	elif ara[i] <= 10:
		police += ara[i]
	else:
		police += 10
print(cnt)


n = int(input())
p = [int(i) for i in input().split()]
count = 0
k = 0
for i in range(len(p)):
	if p[i] == -1 and k >= 1 and (k <= 10):
		k = k - 1
	elif p[i] == -1 and k <= 10:
		count = count + 1
	else:
		k = k + p[i]
print(count)


n = int(input())
l = [int(x) for x in input().split()]
(p, ans) = (0, 0)
for i in l:
	if i < 0 and p == 0:
		ans += 1
	else:
		p += i
print(ans)


n = int(input())
ar = list(map(int, input().split()))
positive = 0
m = 0
for i in ar:
	if i < 0:
		if positive == 0:
			m += 1
		else:
			positive -= 1
	else:
		positive += i
print(m)


a = int(input())
b = list(map(int, input().split()))
c = 0
d = 0
for i in b:
	if i > 0:
		c += i
		continue
	if c > 0 and i < 0:
		c -= 1
		continue
	if i < 0:
		d += 1
print(d)


n = int(input())
a = list(map(int, input().split()))
count = 0
count1 = 0
for i in a:
	count = count + i
	if count < 0:
		count1 = count1 + 1
		count = 0
print(count1)


num = int(input())
count = 0
n = 0
action = [int(a) for a in input().split()]
for i in range(num):
	a = action[i]
	if n > 0 or (n == 0 and a > 0):
		n += a
	else:
		count += 1
print(count)


from sys import stdin, stdout

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

def listInput():
	return list(map(int, sin().split()))

def printBS(li):
	if not li:
		return
	for i in range(len(li) - 1):
		stdout.write('%d ' % li[i])
	stdout.write('%d\n' % li[-1])
n = int(sin())
li = listInput()
ans = 0
pcnt = 0
for i in li:
	if i == -1:
		if pcnt == 0:
			ans += 1
		else:
			pcnt -= 1
	else:
		pcnt += i
print(ans)


n = int(input().strip())
(po, ans) = (0, 0)
arr = [int(__) for __ in input().strip().split()]
for i in range(n):
	if arr[i] == -1:
		if po > 0:
			po -= 1
		else:
			ans += 1
	else:
		po += arr[i]
print(ans)


n = int(input())
crime_list = list(map(int, input().split()))
officers = 0
untreated_crimes = 0
while crime_list[-1] > 0 and len(crime_list) > 1:
	crime_list.pop(-1)
for i in crime_list:
	if i > 0:
		officers += i
	elif officers == 0:
		untreated_crimes = untreated_crimes + i
	else:
		officers = officers + i
print(abs(untreated_crimes))


n = int(input())
numbers = list(map(int, input().split()))
(has, occ) = (0, 0)
for num in numbers:
	if num > 0:
		has += num
	elif has > 0:
		has -= 1
	else:
		occ += 1
print(occ)


n = int(input())
case = [int(x) for x in input().split()]
(free, ocur) = (0, 0)
for i in case:
	if i > 0:
		free += i
	elif free >= -i:
		free += i
	else:
		ocur -= i
print(ocur)


import sys
lines = sys.stdin.readlines()
N = int(lines[0].strip())
nums = list(map(int, lines[1].strip().split(' ')))
curr = 0
res = 0
for n in nums:
	if n == -1 and curr == 0:
		res += 1
	else:
		curr += n
print(res)


n = int(input())
a = list()
a = list(map(int, input().split()))
i = 0
k = 0
for x in a:
	if x > 0 and i < 0:
		i = 0
	i += x
	if i < 0:
		k = k + 1
print(k)


t = int(input())
p = list(map(int, input().split()))
s = 0
inv = 0
for i in range(len(p)):
	if p[i] == -1 and s <= 0:
		inv += 1
		p[i] = 0
	s += p[i]
print(inv)


t = int(input())
marc = 0
crime = 0
emp = 0
lista = [int(x) for x in input().split()]
for x in range(len(lista)):
	if lista[x] == -1:
		crime += 1
	elif lista[x] >= 1:
		emp += lista[x]
		crime -= lista[x]
	if crime > 0:
		marc += 1
		crime = 0
print(marc)


length = int(input())
lst = list(map(int, input().split()))
sums = 0
cout = 0
for i in lst:
	sums += i
	if sums < 0:
		cout += 1
		sums = 0
print(cout)


n = int(input())
s = list(map(int, input().split()))
c = 0
h = 0
for i in range(0, n):
	if s[i] < 0:
		if h > 0:
			h -= 1
		elif h == 0:
			c += 1
	if s[i] > 0:
		h += s[i]
print(c)


n = int(input())
events = input().split()
cops = 0
prest = 0
for i in range(n):
	event = int(events[i])
	if event == -1 and cops == 0:
		prest += 1
	elif event == -1:
		cops -= 1
	else:
		cops += event
print(prest)


n = int(input())
queue = [int(x) for x in input().split()]
ans = 0
cur = 0
for i in range(n):
	if queue[i] == -1:
		if cur > 0:
			cur -= 1
		else:
			ans += 1
	else:
		cur += queue[i]
print(ans)


a = input()
b = list(map(int, input().split()))
c = 0
for r in range(0, len(b)):
	if b[r] < 0:
		c = c + b[r]
	elif r < len(b) - 1:
		b[r + 1] = b[r + 1] + b[r]
	r += 1
print(-c)


n = int(input(''))
l = list(map(int, input().split(' ')))
cont = 0
policias = 0
for k in l:
	if k > 0:
		policias += k
	elif policias + k < 0:
		cont += 1
	else:
		policias += k
print(cont)


x = int(input())
a = list(map(int, input().split()))
b = []
counter = 0
note = 0
for i in a:
	if note + i < 0:
		counter += 1
	else:
		note = note + i
print(counter)


input()
x = list(map(int, input().split()))
buffer = 0
ans = 0
for i in x:
	if i > 0:
		buffer += i
	if i < 0:
		buffer += i
		if buffer < 0:
			ans += abs(buffer)
			buffer = 0
print(ans)


from sys import stdin
input()
z = list(map(int, stdin.readline().split()))
cnt = 0
recruit = 0
for i in z:
	if i < 0 and recruit == 0:
		cnt += 1
	elif i < 0 and recruit > 0:
		recruit -= 1
		if recruit <= 0:
			recruit = 0
	else:
		recruit += i
print(cnt)


n = int(input())
x = map(int, input().split())
(k, res) = (0, 0)
for elm in x:
	if elm != -1:
		k += elm
		continue
	if elm == -1 and k > 0:
		k -= 1
	else:
		res += 1
print(res)


def main(events):
	(curr_officers, unsolved_crimes) = (0, 0)
	for event in events:
		if event > 0:
			curr_officers += event
		elif curr_officers >= 1:
			curr_officers -= 1
		else:
			unsolved_crimes += 1
	return unsolved_crimes
n = int(input())
events = input().split()
events = [int(event) for event in events]
print(main(events))


n = int(input())
lst = list(map(int, input().split()))
stack = []
count = 0
for i in lst:
	if i >= 1:
		for _ in range(i):
			stack.append(1)
	if i == -1:
		if len(stack) == 0:
			count += 1
		else:
			stack.pop()
print(count)


n = int(input())
li = [int(x) for x in input().split()]
m = 0
cr = 0
for i in range(len(li)):
	if li[i] == -1:
		if m <= 0:
			cr = cr + 1
		else:
			m = m - 1
	else:
		m = m + li[i]
print(cr)


import sys
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
from collections import Counter
import collections
import math
import heapq
import re

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

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

def most_frequent(list):
	return max(set(list), key=list.count)

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

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def Convert(string):
	li = list(string.split(''))
	return li

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
prime = []
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j

def main():
	n = inin()
	a = ain()
	count = 0
	temp = 0
	for i in range(n):
		if a[i] == -1 and temp == 0:
			count += 1
		elif a[i] == -1 and temp > 0:
			temp -= 1
		else:
			temp += a[i]
	print(count)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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()


n = int(input())
j = input().split()
l = len(j)
i = 0
while i < l:
	j[i] = int(j[i])
	i = i + 1
count = 0
crime = 0
hire = 0
for k in j:
	if k < 0:
		f = 0 - k
		if f > hire:
			count = count + f - hire
			hire = 0
		else:
			hire = hire - f
	else:
		hire = hire + k
print(count)


def Police(n, s):
	p = 0
	c = 0
	for i in range(n):
		if s[i] >= 1:
			p = p + s[i]
		if s[i] == -1:
			if p <= 0:
				c = c + 1
			else:
				p = p - 1
	return c
x = int(input())
res = [int(n) for n in input().split()]
print(Police(x, res))


def crime(l):
	c = 0
	p = 0
	a = 0
	for i in l:
		if i == -1:
			if p == 0:
				c += 1
			else:
				p -= 1
		else:
			p += i
	return c
n = int(input())
l = list(map(int, input().split()))
print(crime(l))


n = int(input().strip())
events = list(map(int, input().strip().split()))
available_officers = 0
crimes = 0
for e in events:
	if e == -1:
		if available_officers == 0:
			crimes += 1
		else:
			available_officers -= 1
	else:
		available_officers += e
print(crimes)