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