#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n], count = 0, sum = 0;
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < n; i++) {
    if (arr[i] < 0) {
      if (sum <= 0)
        count++;
      else
        sum--;
    } else
      sum += arr[i];
  }
  cout << count << endl;
  return 0;
}
