#include <iostream>
using namespace std;
#include <math.h>
int main (){
int n;
cin>>n;
int arr[n];
for (int i=0;i<n;i++){
cin>>arr[i];
}
int pre[n] ={0};
for (int i=0;i<n;i++){
if (i==0) pre[i] = arr[i];
else pre[i]+=(pre[i-1]+arr[i]);
}
int min =pre[0];
for (int i=0;i<n;i++) if (pre[i]<min) min = pre[i];
if (min>0) cout <<0<<endl;
else {
if (min==0) cout <<min+1<<endl;
else {
min = abs(min) +1;
cout <<min<<endl;
}
}
return 0;
}