#include using namespace std; using ll = long long; #define FOR(i,a,b) for(ll i=(a);i<(b);++i) #define ALL(v) (v).begin(), (v).end() #define p(s) cout<<(s)<> N; vector A(N); FOR(i, 0, N){ cin >> A.at(i); } sort(ALL(A)); ll median = A[N/2]; ll cost = 0; for(ll a : A){ cost += abs(a - median); } p(cost); return 0; }