#include <bits/stdc++.h>
using namespace std;
inline void pisz(int n) { printf("%d\n", n); }
inline int rectCount(int n, int m) { return (m * n * (n + 1) * (m + 1)) / 4; }
vector<int> rem(vector<int> vect, int num) {
  vector<int> myVector = vect;
  std::vector<int>::iterator position =
      std::find(myVector.begin(), myVector.end(), num);
  if (position != myVector.end()) {
    myVector.erase(position);
  }
  return myVector;
}
const int fx[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const int fxx[8][2] = {{0, 1}, {0, -1}, {1, 0},  {-1, 0},
                       {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
template <typename T, typename TT>
ostream& operator<<(ostream& s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, vector<T> t) {
  for (int i = 0; i < ((int)((t).size())); i++) s << t[i] << " ";
  return s;
}
const string numbers = "0123456789ABCDEFGHI";
string baseConv(int n, int b) {
  int currQ = n;
  string str, output;
  while (true) {
    str += numbers[currQ % b];
    currQ /= b;
    if (currQ == 0) break;
  }
  for (int i = str.size() - 1; i >= 0; i--) {
    output += str[i];
  }
  return output;
}
void solveQues() {
  int t;
  cin >> t;
  vector<int> nums(t);
  int freePol = 0, untreatedCrime = 0;
  for (int i = 0; i < t; i++) {
    cin >> nums[i];
    if (nums[i] > -1)
      freePol += nums[i];
    else {
      if (freePol == 0)
        untreatedCrime++;
      else
        freePol--;
    }
  }
  cout << untreatedCrime << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  ;
  cin.tie(NULL);
  cout.tie(NULL);
  solveQues();
  return 0;
}
