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