Source Code
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;

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

        sum+=x;
        if(sum>0) continue;
        ans+=1-sum;
        sum=1;
    }

    cout<<ans;
}
Copy
Zeina The Business Owner YazanIstatiyeh
GNU G++17
10 ms
1.0 MB
Accepted