#include using namespace std; #define modulo 1000000007 #define mod(mod_x) ((((long long)mod_x+modulo))%modulo) #define Inf 10000000.0 long long get_score(vector &a,int m){ if(m>=a.size())return 0; long long ret = 0; long long S = 0; for(int i=m-1;i>=0;i--){ S += a[i]; S += a[a.size()-1 - (m-1-i)]; S -= 2*a[m]; ret = max(ret,S); } return ret; } int main(){ int N; cin>>N; vector a(N); for(int i=0;i>a[i]; } sort(a.begin(),a.end()); int left = 0; int right = N-1; while(right-left>2){ int m1 = left + (right-left)/3; int m2 = m1 + (right-left)/3; if(get_score(a,m1)