中位数
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 1e5 + 10;
int n;
int q[N];
int main()
{
scanf("%d", &n);
for (int i = 0; i < n; i ++ ) scanf("%d", &q[i]);
sort(q, q + n);
int res = 0;
for (int i = 0; i < n; i ++ ) res += fabs(q[i] - q[n >> 1]);
printf("%d\n", res);
return 0;
}