Racing horses--sigsegv error

iam not able to solve sigsegv error…can please tell me what should i change in the solution…
sigsegv runtime error
question:https://www.codechef.com/problems/HORSES

#include<stdio.h>
#include<math.h>

int main()
{
int s[50],N,T,k[50][50],min,i,j;
scanf("%d\n",&T);
scanf("%d\n",&N);

for(i=0;i<N;i++)
{
    scanf("%d\n",&s[i]);

}

min=abs(s[0]-s[1]);
for(i=0;i<N;i++)
{
for(j=0;j<N;j++)
{
if(i!=j)
{
k[i][j]=abs(s[i]-s[j]);
if(min>k[i][j])
min=k[i][j];
}
}
}
printf("%d\n",min);
}

Please format your code or link your submission when you ask for help in CC Discuss. It helps to improve the readability of your code.

Note that you have declared s[50] where N can be as large as 5000.