#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int count = 0, p = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x > 0) p += x;
    ;
    if (p == 0 && x < 0) count++;
    if (x < 0 && p > 0) p--;
  }
  cout << count;
}
