#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int tt = 1;
  while (tt--) {
    long long n, i, s = 0, x, ans = 0;
    cin >> n;
    for (i = 0; i < n; ++i) {
      cin >> x;
      if (x >= 0)
        s += x;
      else {
        if (s == 0)
          ans++;
        else
          s--;
      }
    }
    cout << ans;
  }
}
