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