Calculate the sum

#include
#include <math.h>
using namespace std;

int main()
{
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
int Q;
cin >> Q;
int x[Q];
for (int i = 0; i < Q; i++)
{
cin >> x[i];
}
int sum1[n];
for (int i = 0; i < n; i++)
{
int j = i - x[0];
if (j < 0)
{
j = j + n;
}

	sum1[i] = a[i] + a[j];
}

int sum2[n];
for (int i = 0; i < n; i++)
{
	int j = i - x[1];
	if (j < 0)
	{
		j = j + n;
	}

	sum2[i] = sum1[i] + sum1[j];
}

int sum = 0;
for (int i = 0; i < n; i++)
{
	sum = sum + sum2[i];
}

int temp;
temp = (sum) % (1000000007);
cout << temp;
return 0;

}

it have passed only one test case why plz correct my code

Hi @sahilkumar23102003_bbf6ee38349d98a1
Refer this–>

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.