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