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

int main(){

	int t[10000], wait, sum, n;

	while(cin >> n){
		if(n == 0) break;
			
		for(int i=0; i<n; i++){
			cin >> t[i];
		}
	
		wait = 0;
		sum = 0;
		sort(t, t+n);
		for(int i=0; i<n-1; i++){
			wait += t[i];
			sum += wait;
		}
		
		cout << sum << endl;
		
	}

	return 0;

}