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

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> input(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> input[i];
		}
		sort(input.begin(), input.end());
		unsigned long long int sum = 0;
		unsigned long long int ans = 0;
		for(int i = 0; i < input.size() - 1; ++i)
		{
			sum += input[i];
			ans += sum;
		}
		cout << ans << endl;
	}
}

int main()
{
	solve();
	return(0);
}