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