#include<stdio.h>
#include<math.h>
#include<string.h>
int main(void){
int a,b,c,d;
while(scanf("%d",&a)!= EOF){
c=0;d=0;
while(a--){
scanf("%d",&b);
if(b>0)
c=c+(0.5)*b;
else c=c+b;
if(c<0)d++;}
printf("%d\n",d);}
return 0;}