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