#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n;
    while (cin >> n, n) {
        vector<long long> v(n);
        for (int i=0; i<n; ++i) cin >> v[i];
        sort(v.begin(), v.end());
        vector<long long> t(n);
        t[0] = 0;
        for (int i=1; i<(int)v.size(); ++i) {
            t[i] += t[i-1] + v[i-1];
        }
        int sum = 0;
        for (int i=0; i<(int)t.size(); ++i) {
            sum += t[i];
        }
        cout << sum << endl;
    }
    return 0;
}