#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, office = 0, num_crime = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x > 0)
      office += x;
    else {
      if (office > 0)
        office--;
      else
        num_crime++;
    }
  }
  cout << num_crime << endl;
  return 0;
}
