#include <iostream>
#include <math.h>
#define ll long long int
using namespace std;
int main() {
ll n, day_profit, max_lend = 0;
ll sum = 0;
cin >> n;
ll n_copy = n;
while (n_copy--) {
cin >> day_profit;
sum += day_profit;
if (sum < 0 && (abs(sum) + 1 > max_lend))
max_lend = abs(sum) + 1;
}
cout << max_lend;
}