this is the code that i have written but the output is not correct and also the no of count of 0 is not appropiate in the code
using namespace std;
int main(){
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
int count=0;
int q;
cin>>q;
while(q--){
int m;
cin>>m;
int l,r,x;
cin>>l>>r>>x;
int sum=0;
for(int i=l-1;i<r;i++){
if(arr[i]==0){
count++;
}
sum+=arr[i];
}
sum+=count*x;
cout<<sum<<endl;
}
}