#include<string>
#include <iostream>
using namespace std;
int main() {
int prev, succ, n, a[1000], s, c,g, result=0;
cin >> n;
a[0] = 0;
for (int i = 1; i < n; i++) {
cin >> a[i];
}
for (int i = 1; i < n; i++) {
if (a[i] < 0) {
s = a[i - 1] + a[i];
if (s < 0) {
g = abs(a[i]);
result++;
c = result + a[i];
if (c == 0) {
result++;
}
}
}
}
result--;
cout << result;
}