#include <bits/stdc++.h>
using namespace std;
int n, tam, num, untreaty;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  for (int x = 1; x <= n; x++) {
    cin >> num;
    if (num == -1) {
      if (tam > 0) {
        tam--;
      } else {
        untreaty++;
      }
    } else {
      tam += num;
    }
  }
  cout << untreaty << "\n";
}
