#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int cases = 0;
  int can_solved = 0;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] > 0) {
      can_solved += arr[i];
    }
    if (arr[i] < 0) {
      if (can_solved == 0) {
        cases += arr[i];
      }
      if (can_solved > 0) {
        can_solved += arr[i];
      }
    }
  }
  cout << cases * -1;
}
