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

int main () {
	int n;
	while (cin >> n, n) {
		vector<int> a;
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			a.push_back(x);
		}
		sort(a.begin(), a.end());
		int wait = 0;
		int result = 0;
		for (unsigned i = 0; i < a.size(); i++) {
			result += wait;
			wait += a[i];
		}
		cout << result << endl;
	}
	return 0;
}