提交时间:2023-09-07 13:33:19
运行 ID: 101249
#include<algorithm> #include<iostream> #include<cmath> using namespace std; int main() { int a; cin>>a; int b[a],sum=0,sum1=0; for(int s=0; s<a; s++) cin>>b[s]; sort(b,b+a,greater<int>()); for(int s=a-1; s>=0; s--) { if(s<a-2) sum1+=sum; sum+=b[s]; } cout<<sum1+sum; }