#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int currentEvent;
  int officerCount = 0;
  int untreatedCount = 0;
  for (int i = 0; i < n; ++i) {
    cin >> currentEvent;
    if (currentEvent == -1) {
      if (officerCount > 0)
        officerCount--;
      else
        untreatedCount++;
    } else {
      officerCount += currentEvent;
    }
  }
  cout << untreatedCount << "\n";
  return 0;
}
