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

int main(){
	int n, a[10000];
	while(cin >> n, n){
		int ans = 0, tmp = 0;
		for(int i = 0;i < n;i++)cin >> a[i];
		sort(a, a+n);
		for(int i = 0;i < n-1;i++){
			tmp += a[i];
			ans += tmp;
		}
		cout << ans << endl;
		//cout << endl << ans << endl;
		//for(int i = 0;i < n;i++)cout << a[i] << " ";
		//cout << ans << endl;
	}
	return 0;
}
//23469
//2  2
//5  7
//9  16
//15 31