Dividing array problem

getting wrong answers. Please help

@Rakshitgarg99 this is the correct app

int main() {
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
long long int mi=0,ma=0;
for(int i=0;i<n/2;i++)
{
ma+=abs(a[n-i-1]-a[i]);
}
for(int i=0;i<n-1;i+=2)
{
mi+=abs(a[i+1]-a[i]);
}
cout<<mi<<" "<<ma<<endl;
}
return 0;
}
i dont think you are doing this exactly

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.