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

int main()
{
	int n;
	long long m[10000], wait[10000] = {0},waitsum=0;

	while (cin>>n)
	{
		if (n == 0) break;
		for (int i = 0; i < n; i++)
		{
			cin >> m[i];
		}
		
		sort(m, m+n);		//??????????????????

		for (int i = 0; i < n; i++)
		{
			wait[i + 1] = m[i]+wait[i];
		}
		for (int i = 0; i < n; i++)
		{
			waitsum += wait[i];
		}

		cout << waitsum << endl;

	}

	return 0;
}