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