合并果子。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define maxn 50050
using namespace std;
long long n,x,ans=;
priority_queue <long long,vector<long long>,greater<long long> > q;
int main()
{
scanf("%lld",&n);
for (long long i=;i<=n;i++)
{
scanf("%lld",&x);
q.push(x);
}
while (q.size()!=)
{
long long a=q.top();q.pop();
long long b=q.top();q.pop();
ans+=a+b;q.push(a+b);
}
printf("%lld\n",ans);
return ;
}