贪心
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef __int64 ll;
int const MAXN = 300010;
ll a[MAXN];
int main(){
int n;
scanf("%d",&n);
ll s = 0;
for(int i = 1;i <= n;i++){
scanf("%I64d",&a[i]);
s += a[i];
//a[i] += a[i - 1];
}
sort(a+1,a+n+1);
if(n == 1)cout<<s<<endl;
else{
ll ss = s;
int cnt = 0;
int i = 1;
while(i <= n){
cnt++;
if(cnt & 1){
ss -= a[i];
if(ss == 0)break;
s += a[i++];
}
else s += ss;
//cout<<ss<<endl;
}
cout<<s<<endl;
}
return 0;
}