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