#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define int long long
using namespace std;

signed main()
{
	int a;
	while (cin >> a, a) 
	{
		int k = 0;
		vector<int>s(a);
		for (int b = 0; b < a; b++)cin >> s[b];
		sort(s.begin(), s.end());
		for (int p =0; p<a-1; p++) {
			k += s[p] * (s.size() - 1 - p);
		}
		cout << k << endl;
	}
}