#include<bits/stdc++.h> using namespace std; const int N=1e6; int n,t[N]; long long s=0; int main() { cin>>n; for(int i=0;i<n;i++)cin>>t[i]; sort(t,t+n); for(int i=0;i<n;i++)s+=t[n-i-1]*i; cout<<s; return 0; }