#include <bits/stdc++.h>
int main() {
  int t, i, p, result, count;
  scanf("%d", &t);
  result = 0;
  count = 0;
  for (i = 0; i < t; i++) {
    scanf("%d", &p);
    if (p == -1 && result == 0)
      count++;
    else
      result += p;
  }
  printf("%d", count);
  return 0;
}
