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