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

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