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