#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>

#define PI 3.14159265359

#define INF 1000000;

using namespace std;


int main()
{
	int n, time[10000], wait_time;
	long long wait_sum;
	
	while (cin >> n)
	{
		if (n == 0) break;
		
		for (int i=0; i<n; i++) cin >> time[i];
		sort(time, time + n);
		
		wait_sum = 0;
		wait_time = 0;
		for (int i=0; i<n-1; i++)
		{
			wait_time += time[i];
			wait_sum += wait_time;
		}
		
		cout << wait_sum << endl;
	}
	
	
	return 0;
}