#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
int a,b,c[500],d;
cin>>a;
for(int x=0;x<a;x++){
cin>>b;
for(int y=0;y<b;y++){
cin>>c[y];
}
sort(c,c+b);
d=0;
for(int y=0;y<b;y++){
d=d+abs(c[y]-c[b/2]);
}
cout<<d<<endl;
}
system("pause");
return 0;
}
沒有留言:
張貼留言