#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	for(;;) {
		long long n, a[10001],sum;
		cin >> n; if(n==0) break;
		for(int i=0;i<n;i++) cin >> a[i];
		sort(a, a+n, greater<int>());
		sum = 0;
		for(int i=1;i<n;i++ ) sum += a[i]*i;
		cout << sum << endl;
	}
	return 0;
}