#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	while (cin >> n){
		if (n == 0)break;
		vector<int>l;
		long long sum;
		for (int i = 0; i < n; i++) {
			cin >> sum;
			l.push_back(sum);
		}
		sort(l.begin(), l.end());
		sum = 0;
		for (int i = 0; i < n; i++) {
			sum += l[i] * (n - i - 1);
		}
		cout << sum << endl;
	}
	return 0;
}