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