#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, officers = 0, crimeHappened = 0, k;
  cin >> n;
  while (n--) {
    cin >> k;
    if (k == -1) {
      if (officers > 0) {
        officers--;
      } else {
        crimeHappened++;
      }
    } else {
      officers += k;
    }
  }
  cout << crimeHappened;
}
