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