#include
#include
#define ll long long
using namespace std;
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);
ll minAns=0, maxAns=0;
for (int j = 0; j < n/2; ++j) {
minAns += abs(a[j * 2 + 1] - a[j * 2]);
maxAns+=abs(a[j]-a[n-j-1]);
}
cout<<minAns<<" "<<maxAns<<endl;
}
return 0;
}
It passed 1 test case and getting tle in second.