#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j = 0;
  cin >> n;
  int a[n];
  for (i = 0; i < n; ++i) cin >> a[i];
  for (i = j; i < n; ++i)
    for (j = i + 1; j < n; ++j) {
      if (a[i] > 0) {
        --a[i];
        ++a[j];
      } else
        break;
    }
  j = 0;
  for (i = 0; i < n; ++i)
    if (a[i] < 0) ++j;
  cout << j;
}
