#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int t;
  cin >> t;
  int count = 0;
  int pos = 0;
  int temp;
  while (t--) {
    cin >> temp;
    if (temp < 0) {
      if (pos > 0) {
        pos--;
      } else {
        count++;
      }
    } else {
      pos += temp;
    }
  }
  cout << count;
}
