#include <bits/stdc++.h>
using namespace std;
int main() {
  int escape = 0, g = 0, n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (g == 0) {
      if (a[i] > 0)
        g += a[i];
      else
        escape++;
    } else {
      if (a[i] > 0)
        g += a[i];
      else
        g--;
    }
  }
  cout << escape << endl;
}
