#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, temp, ans = 0, recr = 0, i;
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> temp;
    if (temp == -1) {
      if (recr > 0) {
        recr -= 1;
      } else {
        ans += 1;
      }
    } else {
      recr += temp;
    }
  }
  cout << ans << endl;
  return 0;
}
