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