#include <bits/stdc++.h>
using namespace std;
void spectrum() {
  int n, ct = 0, CT = 0, P = 0, x;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == -1) {
      if (!P)
        ct++;
      else
        P--;
    } else
      P += x;
  }
  cout << ct << endl;
}
int main() { spectrum(); }
