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