#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());
        long long sum = 0;
        for (int i=1; i<n; ++i) {
            sum += v[i-1] * (n - i);
        }
        cout << sum << endl;
    }
    return 0;
}