#include using namespace std; using ll=long long; int main(){ ll n; cin>>n; vector v(n); ll cnt=0; for(int i=0;i>v[i]; cnt+=v[i]; } sort(v.begin(),v.end()); if(n%2){ ll ans=0; ll m=n/2; for(int i=0;im){ ll z=v[m]+v[m-1]; ans=max(ans,z*(n-1)/2-(cnt-v[i])); } } cout<