#include <bits/stdc++.h>
bool isFile;
using namespace std;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
void _();
void faster() {
  _();
  if (isFile) {
    freopen(
        "taskA"
        ".in",
        "r", stdin);
    freopen(
        "taskA"
        ".out",
        "w", stdout);
  }
  if (1) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  }
}
const long long INF = 1e18;
const int inf = 2e9;
const int MOD = 1e9 + 7;
const long double PI = acos(-1);
const long double EPS = 3E-16;
const int ALPHA = 27;
const int N = (int)2e5 + 5;
const int M = 1234;
namespace MATH_CAL {
const int mod = MOD;
inline long long add(long long a, long long b) {
  return a + b >= mod ? a + b - mod : a + b;
}
inline long long sub(long long a, long long b) {
  return a - b < 0 ? a - b + mod : a - b;
}
inline long long mul(long long a, long long b) {
  return (long long)a * b % mod;
}
inline void Add(long long &a, long long b) { (a += b) >= mod ? a -= mod : 0; }
inline void Sub(long long &a, long long b) { (a -= b) < 0 ? a += mod : 0; }
inline long long qpow(long long x, long long n) {
  long long r = 1;
  for (; n; n /= 2, x = mul(x, x))
    if (n & 1) r = mul(r, x);
  return r;
}
inline long long mod_inv(long long x) { return qpow(x, mod - 2); }
inline long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
}  // namespace MATH_CAL
using namespace MATH_CAL;
void solve() {
  int n;
  cin >> n;
  int ans = 0;
  int free_police = 0;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    if (t == -1) {
      if (free_police > 0) {
        free_police--;
      } else {
        ans++;
      }
    } else {
      free_police += t;
    }
  }
  cout << ans << endl;
}
void _() { isFile = 0; }
int main() {
  faster();
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
