#include #define REP(i,n) for(int i=0,i##_len=int(n);i>N; vector a(N); REP(i, N) cin >> a[i]; sort(All(a)); vector S(N+1); REP(i,N) S[i+1]=S[i]+a[i]; ll ans=0; REP(i,N){ int l=0,r=N; while(l+1>1; if(i-mid<0||N-mid<=i){ r=mid; continue; } if(a[N-mid]>=a[i-mid]) l=mid; else r=mid; } ans=max(ans,S[N]-S[N-l]+(S[i]-S[i-l])-(2*l)*a[i]); } cout<