#include <iostream>
using namespace std;
int main() {
int days;
cin >> days;
int* arr = new int[days];
for (int i = 0;i < days;i++) {
cin >> arr[i];
}
int n = 0;
int lend = 0;
for (int i = 0;i < days;i++)
{
n += arr[i];
if (n < 1)
{
lend += 1 - n;
n += lend;
}
}
cout << lend;
return 0;
}