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

int main(){
    int n;
    while (1){
	cin >> n;
	if (n == 0) break;
	int t;
	vector<long long> v;
	for (int i = 0; i < n; i++){
	    cin >> t;
	    v.push_back(t);
	}
	sort(v.begin(), v.end());
	int sum = 0, m = 0;
	for (int i = 0; i < v.size(); i++){
	    sum += m;
	    m += v[i];
	}
	cout << sum << endl;
    }
}