#include <bits/stdc++.h>
int main() {
  int n, i, rez, now_moment, now_free;
  while (scanf("%d", &n) > 0) {
    rez = 0;
    now_moment = 0;
    now_free = 0;
    for (i = 0; i < n; i++) {
      scanf("%d", &now_moment);
      if (now_moment >= 0)
        now_free += now_moment;
      else if (now_free > 0)
        now_free--;
      else
        rez++;
    }
    printf("%d\n", rez);
  }
  return 0;
}
