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

int main() {
	int a;
	while (cin >> a, a) {
		int time[10003];
		for (int i = 0;i < a;i++) {
			cin >> time[i];
		}
		sort(time, time + a);

		long long sum = 0;
		for (int i = 0;i < a;i++) {
			sum += time[i] * (a - i - 1);
		}
		cout << sum << endl;
	}
	return 0;
}