#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a, s = 0, ans = 0;
  while (n--) {
    cin >> a;
    s += a;
    ans = (ans < s) ? ans : s;
  }
  cout << -ans << endl;
  return 0;
}
