Source Code
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

typedef long long int ll;
#define loop(n) for(ll i=0;i< ll(n); i++)


void solve() {
	ll n;
	cin >> n;

	int sa= 0;
	int total = 0;
	loop(n) {
		ll val;
		cin >> val;
		total += val;
		while(total <= 0 ) {
			sa += (total*-1) + 1;
			total = 1;
		}
	}

	cout << sa << endl;
}

int main() {
	solve();
	return 0;
}
Copy
Zeina The Business Owner Qusay
GNU G++17
27 ms
1.0 MB
Accepted