#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  int tp;
  cin >> n;
  int ans = 0, police = 0;
  while (n-- && cin >> tp) {
    if (tp < 0 && police == 0)
      ans++;
    else if (tp < 0 && police > 0)
      police += tp;
    if (tp > 0) police += tp;
  }
  cout << ans << endl;
  return 0;
}
