#include using namespace std; using Lint=long long; int main() { int N; cin>>N; vector a(N); for(int i=0;i>a[i]; sort(a.begin(),a.end()); vector sum(N+1); for(int i=0;i1){ int mid=(ok+ng)/2; if(a[i-mid]+a[N-mid]-2*a[i]>0) ok=mid; else ng=mid; } ans=max(ans,(sum[i]-sum[i-ok])+(sum[N]-sum[N-ok])-2LL*ok*a[i]); } cout<