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: interview

Starter code:

Solutions:
"""
Codeforces Round 244 Div 1 Problem A

Author  : chaotic_iak
Language: Python 3.3.4
"""

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

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

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)

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


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

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())
seq = list(map(int, input().split()))

avail_cops = 0
crimes = 0

for event in seq:
	if event > 0:
		avail_cops += event
	else:
		if avail_cops == 0:
			crimes += 1
		else:
			avail_cops -= 1
print(crimes)


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)

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)

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


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

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())
l = list(map(int, input().split()))
p, c = 0, 0

for i in l:
    if i > 0:
        p += i
    else:
        if p > 0:
            p -= 1
        else:
            c += 1

print(c)


#!/usr/bin/env python

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

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


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)

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

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)

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

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

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)