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

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> ts(n);
        for (int i = 0; i < n; i++) {
            cin >> ts[i];
        }
        sort(ts.begin(), ts.end());
        long long sum = 0, ans = 0;
        for (int i = 0; i < n; i++) {
            ans += sum;
            sum += ts[i];
        }
        cout << ans << endl;
    }
}