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