#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; ll f(ll x, const vector& v, int K){ vector ret; rep(i,v.size()){ ret.push_back(abs(v[i]-x)); } sort(ALLOF(ret)); ll sum = 0; rep(i,v.size()){ if(i> N >> K; vector v(N); rep(i,N) cin >> v[i]; ll ret = f(v[N/2],v,K); ret = min(ret, f(v[0],v,K)); ret = min(ret, f(v[N-1],v,K)); { ll l = v[0], r = v[N/2]; rep(i,100){ if(f((l+l+r)/3,v,K)