#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const double eps = 1e-6;
const int mod = inf + 7;
const int N = 100000;
long long n, a[100100], cur, ans, x;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    if (x < 0) {
      if (cur > 0)
        cur--;
      else
        ans++;
    } else {
      cur += x;
    }
  }
  cout << ans << "\n";
}
