#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int n;
  int crime, police;
  int event;
  crime = 0;
  police = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> event;
    if (police + event < 0)
      crime++;
    else if (event >= 1)
      police += event;
    else
      police -= 1;
  }
  cout << crime << endl;
}
