HORSES getting wrong answer

Here is my source code:

#include
using namespace std;

int main() {
int t,n;
unsigned long long sum=0;
cin>>t;
long long arr[n];
for(int k=0;k<t;k++){
cin>>n;
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(arr[i]>arr[j])
{
sum=arr[i];
arr[i]=arr[j];
arr[j]=sum;
}
}
}
cout<<arr[1]-arr[0]<<"\n";
}
return 0;
}
My ans is not coming in the problem HORSES

Share a link of the solution. Here it seems all messed up.