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

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());
        int sum = 0, t = 0;
        for (int i=0; i<(int)v.size()-1; ++i) {
            t += v[i];
            sum += t;
        }
        cout << sum << endl;
    }
    return 0;
}