1 #include<cstdio> 2 #include<algorithm> 3 using namespace std; 4 long long a[300010]; 5 long long n; 6 int main() 7 { 8 scanf("%lld",&n); 9 for (long long i=1;i<=n;i++) scanf("%lld",&a[i]); 10 sort(a+1,a+n+1); 11 long long ans=0; 12 for (int i=1;i<n;i++) ans+=a[i]*(i+1); 13 ans+=a[n]*n; 14 printf("%lld\n",ans); 15 return 0; 16 }
时间: 2024-08-09 19:57:35