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