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