Source Code
#include <bits/stdc++.h>
using namespace std;

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

int x,R=0,sum=0;
for(int i=0 ; i<n; i++)
{
cin>>x;

if(x<0)
{
    R+=-x-sum;
    sum+=x;
}
    else if(x>0){
        sum+=x;
    }
}

cout<<R;
}

int main() {
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Copy
Zeina The Business Owner TATAKAE
GNU G++17
3 ms
660 KB
Wrong Answer