#include <bits/stdc++.h>
using namespace std;
map<string, long long> mp;
string maxp;
int main() {
  long long n;
  cin >> n;
  long long a[n];
  long long Max = 0, ans = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < 0) {
      if (Max < 1) {
        ans++;
      } else
        Max--;
    }
    if (a[i] > 0) {
      Max += a[i];
    }
  }
  cout << ans;
  return 0;
}
