2 Test cases passed, 1 failed
#include
#include
using namespace std;
void fun(int n, int arr[]){
int o;
cin>>o;
if(o>=0){
int arra[n];
for(int j=0;j<n;j++){
arra[j]=arr[j];
}
int x;
int sum=0;
//Below loop takes the value of x multiple times
for(int j=1;j<=o;j++){
cin>>x;
if(x>=0 && x<n){
//below loop calculates sum
for(int i=0;i<n;i++){
if((i-x)>=0){
arr[i]=arr[i]+arra[i-x];
}
else if((i-x)<0){
arr[i]=arr[i]+arra[n-x];
}
}
//below loop copies value of one array to other for calculation in next iteration
for(int j=0;j<n;j++){
arra[j]=arr[j];
}
}
}
for(int i=0;i<n;i++){
sum=sum+arr[i];
}
int a=(pow(10,9)+7);
sum=sum%a;
cout<<sum;
}
}
int main() {
int n;
cin>>n;
int arr[n];
if(n>=1 && n<=100000){
for(int x=0;x<n;x++){
cin>>arr[x];
}
fun(n,arr);
}
return 0;
}