wrong answer

i am getting WA in the question while i get right answer at code compile run please help me. #include <stdio.h>

//int main(void) {
// your code goes here #include <stdio.h>
long int a[10000002];
int main(void) {
int t=0,f=0;
long long signed int n=0,q=0,i=0,j=0,w=0,g=0,p=0;
scanf("%d\n",&t);
while(t--)
{
scanf("%lld \n",&n);
for(p=0;p<n;p++)
{
scanf("%ld",&a[p]);
}
scanf("%llu\n",&q);
for(w=0;w<q;w++)
{ f=0;
scanf("%lld %lld\n",&i,&j);
for(g=i;g<=j;g++)
{
f=f+a[g-1];
}
printf("%d\n",f);
}
}
return 0;
}