#include <bits/stdc++.h>

using namespace std;

int main(){

    int n, total;

    while(cin >> n, n){

        int time[n], sum[n];

        for(int i = 0; i < n; ++i){
            cin >> time[i];
        }

        sort(time, time + n);

        sum[0] = 0;
        for(int i = 1; i < n; ++i){
            sum[i] = sum[i - 1] + time[i - 1];
            //cout << "sum" << i << " " << sum[i] << endl;
        }

        total = 0;
        for(int i = 0; i < n; ++i){
            total += sum[i];
        }

        cout << total << endl;

    }

}