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