#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n;

	while (true)
	{
		cin >> n;

		if (n == 0) { break; }

		vector<int> v(n);

		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}

		sort(v.begin(), v.end());

		int sum = 0;

		for (int i = 0; i < n; i++)
		{
			sum += (n - i - 1) * v[i];
		}

		cout << sum << endl;
	}

	return 0;
}