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

int main() {
	long long int i,n,a[10000],all;
	while (1) {
		all = 0;
		cin >> n;
		if (n == 0)break;
		for (i = 0; i < n; i++) {
			cin >> a[i];
		}
		sort(a, a + n);
		for (i = 0; i < n - 1; i++) {
			all += a[i] * (n - i-1);
		}
		cout << all << endl;
	}
	return 0;
}