why am i getting Runtime Error(SIGSEGV) on submitting following code??

why i am getting Runtime Error(SIGSEGV) on submitting following code?
can anyone please help me??

#include<stdio.h>
int main()
{
int t,a,r[10000],b,n,i;

scanf("%d",&t);

while(t>0)
{
	scanf("%d%d",&a,&b);
	scanf("%d",&n);
	r[1]=a;
	r[2]=b;
	for(i=3;i<=n;i++){
		r[i]=r[i-1]-r[i-2];
	}
	if(r[n]>=0)
	printf("%d\n",r[n]);
	
	else
	printf("%d",r[n]+1000000007);
t--;
}
return 0;

}

For n=10000, r[n] doesnt exist here-

if(r[n]>=0)
    printf("%d\n",r[n]);

If this doesnt fix, please give the Q link and your code link sow e can have a look.

thanks for replying but that does not fixes the problem.

link for problem: https://www.codechef.com/problems/CHN08

link for solution: https://www.codechef.com/status/CHN08,ayush_775