Source Code
#include <bits/stdc++.h>

using namespace std;

int main() {
    long long n;
	cin>>n;

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

	cout<<sa<<endl;
	return 0;
}
Copy
Zeina The Business Owner Mohamedmaher
GNU G++17
0 ms
0 KB
Compilation Error