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