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