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