#include <bits/stdc++.h>
using namespace std;
void RI() {}
template <typename... T>
void RI(int &head, T &...tail) {
  scanf("%d", &head);
  RI(tail...);
}
void PRI(int x) { printf("%d\n", x); }
template <typename... Args>
void PRI(int head, Args... tail) {
  fprintf(stderr, "%d ", head);
  PRI(tail...);
}
pair<int, int> operator+(const pair<int, int> &a, const pair<int, int> &b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
pair<int, int> operator-(const pair<int, int> &a, const pair<int, int> &b) {
  return make_pair(a.first - b.first, a.second - b.second);
}
pair<int, int> &operator+=(pair<int, int> &a, const pair<int, int> &b) {
  a.first += b.first;
  a.second += b.second;
  return a;
}
pair<int, int> &operator-=(pair<int, int> &a, const pair<int, int> &b) {
  a.first -= b.first;
  a.second -= b.second;
  return a;
}
template <class T, class U>
bool cmp_second(const pair<T, U> &a, const pair<T, U> &b) {
  return a.second < b.second;
}
template <class T>
T gcd(T a, T b) {
  a = abs(a);
  b = abs(b);
  while (b) {
    T t = b;
    b = a % b;
    a = t;
  }
  return a;
}
template <class T>
pair<T, T> ext_gcd(T a, T b) {
  T a0 = 1, a1 = 0, b0 = 0, b1 = 1;
  if (a < 0) {
    a = -a;
    a0 = -1;
  }
  if (b < 0) {
    b = -b;
    b1 = -1;
  }
  while (b) {
    T t, q = a / b;
    t = b;
    b = a - b * q;
    a = t;
    t = b0;
    b0 = a0 - b0 * q;
    a0 = t;
    t = b1;
    b1 = a1 - b1 * q;
    a1 = t;
  }
  return make_pair(a0, a1);
}
inline int sg(int x) { return x ? (x > 0 ? 1 : -1) : 0; }
inline string concatenate_strings(vector<string> ss) {
  string s;
  for (int i = 0; i < ss.size(); i++) s += ss[i];
  return s;
}
template <class T>
inline vector<T> read_from_string(string s) {
  vector<T> ret;
  stringstream ss(s, stringstream::in);
  while (1) {
    T x;
    ss >> x;
    ret.push_back(x);
    if (ss.eof()) break;
  }
  return ret;
}
int n;
int main(void) {
  int c = 0, sol = 0;
  RI(n);
  for (int i = 0; i < n; i++) {
    int x;
    RI(x);
    if (x < 0) {
      if (c > 0)
        c--;
      else
        sol++;
    } else {
      c += x;
    }
  }
  PRI(sol);
  return 0;
}
