Calculate the sum (not able to get correct ans)

my array is getting updated after every step and updated value is getting added to next index.

#include
using namespace std;
#define for(a,l) for(int i=0;i<=l;i++)

int main(){
int n;
cin>>n;
int arr[n];
for(0,n-1){
cin>>arr[i];
}

int q;
cin>>q;
int s[q];
for(0,q-1){
    cin>>s[i];
}



for(0,q-1){
    int step=s[i];
    for(0,n-1){
    
        if(i-step>=0){
            arr[i]=arr[i]+arr[i-step];
            
        }
        else{
            arr[i]=arr[i]+arr[n-step];
        }
        
    }
}
for(0,n-1){
    cout<<arr[i]<<endl;
}
int sum=0;
for(0,n-1){
     sum=sum+arr[i];
}
cout<<sum<<endl;
return 0;

}

@shivamraj53.sr,
u dont need to shift and add elements
see everytime how many times u shift u r adding the overall sum to the array right.
so just add elements each time sifting is not required.

check this : https://ide.codingblocks.com/s/657171

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.