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

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        int c[n];
        for (int i = 0; i < n; i++) {
            cin >> c[i];
        }
        sort(c, c+n);
        int time = 0;
        for (int i = 0; i < n; i++) {
            time += c[i] * (n - 1 - i);
        }
        cout << time << endl;
    }
    return 0;
}