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;
}