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