#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
long long n, sum, res, a[N];
void solve() {
  cin >> n;
  sum = 0;
  res = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == -1) {
      if (sum > 0)
        sum--;
      else
        res++;
    } else {
      sum += a[i];
    }
  }
  cout << res << "\n";
}
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
