#include <bits/stdc++.h>
const int MOD = 1e9 + 7;
const int MAX_VAL = 1e6 + 2;
const int INF = 0x3f3f3f3f;
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, arr[100002], cnt = 0, occ = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  for (int i = 0; i < n; ++i) {
    if (arr[i] >= 1 || (cnt >= 1 && arr[i] == -1))
      cnt += arr[i];
    else if (cnt == 0 && arr[i] == -1)
      ++occ;
  }
  cout << occ << endl;
  return 0;
}
