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