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 += sa;
		}
	}
	cout << sa << endl;
}

int main() {
	solve();
	return 0;
}
Copy
Zeina The Business Owner Qusay
GNU G++11
5 ms
840 KB
Wrong Answer