using namespace std;
#include<string>
#include <iostream>
int main(){
int n,a[100];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int sum = 0;
int count = 0;
for (int i = 0; i < n; i++) {
if (a[i] == 0)
continue;
sum =sum+a[i];
if(sum<0)
count = count + abs(sum);
}
cout << count;
}