#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int y = 0;
  int sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    if (k > 0) {
      if (sum < 0)
        sum = k;
      else
        sum += k;
    } else
      sum += k;
    if (sum < 0) y++;
  }
  cout << y;
}
