#include <bits/stdc++.h>
using namespace std;
int input[100010];
int main() {
  int i, j, n;
  while (scanf("%d", &n) != EOF) {
    for (i = 1; i <= n; i++) scanf("%d", &input[i]);
    int cur = 0, ans = 0;
    for (i = 1; i <= n; i++) {
      if (input[i] > 0)
        cur += input[i];
      else {
        if (cur > 0)
          cur--;
        else
          ans++;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
