#include <algorithm>
using namespace std;

const int MAX = 10000;
int main()
{
	int N;
	while (cin >> N, N)
	{
		int a[MAX];
		for (int i=0; i<N; i++)
			cin >> a[i];

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

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

		cout << sum << endl;
	}

	return 0;
}