#include #define be(v) (v).begin(),(v).end() #define pb(q) push_back(q) #define rep(i, n) for(int i=0;i> n; vector a(n); rep(i, n){ cin >> a[i]; } sort(be(a)); ll num = a[n / 2]; ll ans = 0; rep(i, n){ ans += abs(a[i] - num); } cout << ans << endl; return 0; }