#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    
    while (cin >> n) {
        if (!n)
            break;

        vector<int> wait;
        int tmp;

        for (int i = 0; i < n; i++) {
            cin >> tmp;
            wait.push_back(tmp);
        }
        sort(wait.begin(), wait.end());

        long sum = 0;
        for (int i = 0; i < wait.size() - 1; i++) 
            sum += (wait.size() - 1 - i) * wait[i];

        cout << sum << endl;
    }

    return 0;
}