#include <bits/stdc++.h>
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    int ans = 0;
    int sum = 0;
    while (n--) {
      int x;
      scanf("%d", &x);
      if (x == -1) {
        if (!sum)
          ans++;
        else
          sum--;
      } else
        sum += x;
    }
    printf("%d\n", ans);
  }
  return 0;
}
