#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, k;
  cin >> t;
  vector<int> a;
  int c = 0, i, p = 0;
  for (i = 0; i < t; i++) {
    cin >> k;
    a.push_back(k);
  }
  for (i = 0; i < t; i++) {
    if (a[i] == -1) {
      if (p == 0) {
        c++;
      } else {
        p += a[i];
      }
    } else {
      p += a[i];
    }
  }
  cout << c;
  return 0;
}
