#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  int hired = 0, untreated, counter = 0, counter2 = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] != -1) {
      hired += a[i];
    } else if (a[i] == -1 && hired != 0) {
      counter++;
      hired--;
    }
    if (a[i] == -1) {
      counter2++;
    }
  }
  untreated = counter2 - counter;
  cout << untreated;
}
