//これが(おそらく)正しい解法 #include #include #define ll long long using namespace std; ll y[100001], d[100001]; int main(){ int n; cin >> n; for(int i=0;i> y[i]; sort(y, y + n); if(y[0] == y[n-1]){ cout << 1 << endl; return 0; } ll t = 0; for(int i=0;i=0;i--){ t += y[n-(n-i)/2] - y[i+1]; d[i] += t; } ll m = 1e18; for(int i=0;i