#include #include using namespace std; int N; long A[2<<17]; long S[2<<17]; main() { cin>>N; for(int i=0;i>A[i]; sort(A,A+N); for(int i=0;i1) { long M=(L+R)/2; if(A[N-M]+A[i-M]>A[i]*2)L=M; else R=M; } ans=max(ans,S[N]-S[N-L]+S[L]-2*L*A[i]); } cout<