wrong ans in racing horses

#include<stdio.h>
int main()
{
int i,t,n,j,a;
scanf("%d",&t);
while(t–)
{
scanf("%d",&n);
long long int s[5001];
for(i=0;i<n;i++)
scanf("%lld",&s[i]);
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(s[i]>s[j])
{
a=s[i];
s[i]=s[j];
s[j]=a;
}
}
}
long long int count;
count=s[1]-s[0];
printf("%lld\n",count);

}
return 0;
}

Do not post the same question twice (or more).