~cpp #include <iostream> #include <algorithm> using namespace std; int testcase, homeNum, i; int sum; int addressList[500]; int main() { cin>>testcase; while(testcase--) { cin>>homeNum; for(i=0; i<homeNum; i++) cin >> addressList[i]; sort(&addressList[0], &addressList[homeNum]); sum=0; for(i=0; i<homeNum; i++) sum+=abs(addressList[i]-addressList[(homeNum-1)/2]); cout << sum << endl; } return 0; }