#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    while(cin>>n){
        vector<unsigned long long>vec,v;
        while(n--){
            unsigned long long t;
            cin>>t;
            vec.push_back(t);
        }
        sort(vec.begin(),vec.end());
        unsigned long long tot=0,ans=0;
        for(int i=1;i<vec.size();i++){
            tot+=vec[i-1];
            v.push_back(tot);
        }
        for(int i=0;i<v.size();i++){
            ans+=v[i];
        }
        cout<<ans<<endl;
    }
}