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