#include <bits/stdc++.h>
using namespace std;
void solve()
{
int n;
cin>>n;
int x,R=0,sum=0;
for(int i=0 ; i<n; i++)
{
cin>>x;
sum+=x;
if(x<0 && sum<=0)
{
R+=-sum;
}
}
cout<<R;
}
int main() {
int t=1;
//cin>>t;
while(t--)
{
solve();
cout<<endl;
}
return 0;
}