#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, num, recuiter = 0, untreated = 0;
  cin >> n;
  while (n--) {
    cin >> num;
    if (num == -1) {
      if (-1 + recuiter < 0)
        untreated++;
      else if (-1 + recuiter >= 0)
        recuiter--;
    } else
      recuiter += num;
  }
  cout << untreated;
}
