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