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

using namespace std;

void solve()
{
	int N;
	while(cin >> N, N)
	{
		vector<int> Vec(N);
		for(int i = 0; i < N; ++i)
		{
			cin >> Vec[i];
		}
		sort(Vec.begin(), Vec.end());
		int sum = 0;
		int time = 0;
		for(int i = 0; i < N - 1; ++i)
		{
			time += Vec[i];
			sum += time;
		}
		cout << sum << endl;
	}
}

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