#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main( void )
{
	int n;
	while ( cin >> n && n != 0 )
	{
		vector <int> times;
		for ( int i = 0; i < n; i++ )
		{
			int t;
			cin >> t;
			times.push_back( t );
		}

		stable_sort( times.begin(), times.end() );

		for ( int i = 1; i < n-1; i++ )
		{
			times[i] += times[i-1];
		}

		int kotae = 0;
		for ( int i = 0; i < n - 1; i++ )
		{
			kotae += times[i];
		}

		cout << kotae << endl;

	}
	return 0;
}