#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double E = exp(1.0);
const double eps = 1e-8;
const double INFD = 1e20;
const long long INFLL = 0x3f3f3f3f3f3f3f3fll;
const int INF = 0x3f3f3f3f;
const int maxn = (int)1e4 + 10;
const int MAXN = (int)1e3 + 10;
const int MOD = (int)1e9 + 7;
int n;
void RUN() {
  while (cin >> n) {
    int num, sum = 0, ans = 0;
    for (int i = 1; i <= n; ++i) {
      cin >> num;
      if (num == -1)
        if (sum == 0)
          ++ans;
        else
          sum--;
      else
        sum += num;
    }
    cout << ans << endl;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  RUN();
  return 0;
}
