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.
The first line of input will contain an integer *n* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>), 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.
# for I/O for local system
from sys import stdin, stdout
from os import path, read, fstat
from io import BytesIO

if (path.exists('Input.txt')):
    stdin = open("Input.txt", "r")
    stdout = open("Output.txt", "w")

# For fast I/O
iinput = BytesIO(read(0, fstat(0).st_size)).readline   # for lots of smalls reads
# iinput = stdin.buffer.readline   # for lots of smalls reads
# iinput = stdin.readline   # default reading
pprint = stdout.write

# Import libraries here whenever required
from random import randint
from math import floor


# Use this because normal dict can sometimes give TLE
class FastDict:
    def __init__(self, func=lambda: 0):
        self.random = randint(0, 1 << 32)
        self.default = func
        self.dict = {}

    def __getitem__(self, key):
        mykey = self.random ^ key
        if mykey not in self.dict:
            self.dict[mykey] = self.default()
        return self.dict[mykey]

    def get(self, key, default):
        mykey = self.random ^ key
        if mykey not in self.dict:
            return default
        return self.dict[mykey]

    def __setitem__(self, key, item):
        mykey = self.random ^ key
        self.dict[mykey] = item

    def getkeys(self):
        return [self.random ^ i for i in self.dict]

    def __str__(self):
        return f'{[(self.random ^ i, self.dict[i]) for i in self.dict]}'


n = int(iinput())
events = list(map(int, iinput().split()))

available_police = 0
crimes = 0

for event in events:
     if event == -1 and available_police == 0:
          crimes = crimes + 1
     elif event == -1 and available_police > 0:
          available_police = available_police -1
     elif event > 0:
          available_police = available_police + event
     
          
pprint(str(crimes))
     





