#include <bits/stdc++.h>
using namespace std;
int main() {
  int event, ghotona;
  cin >> event;
  int hired = 0, untreated = 0;
  for (int i = 0; i < event; i++) {
    cin >> ghotona;
    hired += ghotona;
    if (hired < 0) {
      untreated++;
      hired = 0;
    }
  }
  cout << untreated << endl;
}
