#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	while (cin >> n, n) {
		vector<int> v(n);
		for (int i = 0; i < n; i++) {
			cin >> v[i];
		}
		sort(v.begin(), v.end());
		long long res = 0, sum = v[0];
		for (int i = 1; i < n; i++) {
			res += sum;
			sum += v[i];
		}
		cout << res << endl;
	}
	return 0;
}