#include <bits/stdc++.h>
using namespace std;
int arr[100];
int main() {
  int n = 0, unsol_cr = 0, pol = 0, tmp = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    if (tmp < 0) {
      if (pol == 0)
        unsol_cr = unsol_cr - tmp;
      else if (pol > 0) {
        if (tmp > pol) unsol_cr += (-tmp - pol);
        pol = max(0, pol + tmp);
      }
    } else {
      pol += tmp;
    }
  }
  cout << unsol_cr;
  return 0;
}
