#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n) {
        vector<int> v(n);
        for(int i = 0; i < n; i++) cin >> v[i];

        sort(v.begin(), v.end());
        
        vector<ll> s(n);
        s[0] = 0;
        ll sum = 0;
        for(int i = 1; i < n; i++) {
            s[i] = v[i-1] + s[i-1];
            sum += s[i];
        }
        
        cout << sum << endl;
    }
}