#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum = 0, m = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == -1) m = i;
  }
  int ps = 0;
  for (int i = 0; i <= m; i++) {
    if (a[i] == -1) {
      sum++;
    } else {
      for (int j = i; j <= m; j++) {
        ps += a[j];
        if (ps == -1) {
          sum++;
          ps = 0;
        }
      }
      break;
    }
  }
  cout << sum << endl;
}
