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

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