#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n;
  cin >> n;
  int event, police = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> event;
    if (event == -1) {
      if (police == 0)
        ans++;
      else
        police--;
    } else
      police += event;
  }
  cout << ans;
}
