#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<stack>
#include<queue>
using namespace std;
int n,s;
struct cmp
{
bool operator ()(int x, int y)
{
return x > y;
}
};
priority_queue<int,vector<int>,cmp>q;
void fun()
{
while(!q.empty())
q.pop();
}
int main()
{
while(scanf("%d",&n)!=EOF)
{
for(int i=0;i<n;i++)
{
scanf("%d",&s);
q.push(s);
}
int ans=0;
while(q.size()!=1)
{
int t=q.top();
q.pop();
t+=q.top();
q.pop();
q.push(t);
ans+=t;
//printf("%d\n",t);
}
printf("%d\n",ans);
fun();
}
return 0;
}
05-06
07-16
07-16
07-16
07-16
07-16
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交