#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, sum = 0, c = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a > 0)
      sum = sum + a;
    else {
      if (sum > 0)
        sum -= 1;
      else
        c++;
    }
  }
  cout << c << endl;
  return 0;
}
