#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  while (~scanf("%d", &n)) {
    int a, sum = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &a);
      if (a > 0)
        sum += a;
      else {
        if (sum > 0)
          sum--;
        else
          ans++;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
