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

int main() {
	int N;
	while (cin >> N, N!=0) {
		int time[N];
		for (int i=0; i<N; i++)
			cin >> time[i];

		sort(&time[0], &time[N]);

		int sum = 0;
		int n = N;
		for (int i=0; i<N; i++)
			sum += time[i] * (--n);

		cout << sum << endl;
	}

	return 0;
}