#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int n;

	while( cin >> n && n ){
		vector< int > line;
		for( int i = 0; i < n; ++i ){
			int d;
			cin >> d;
			line.push_back( d );
		}
		sort( line.begin(), line.end() );
		long long output = 0;
		for( int i = 0; i < n - 1; ++i ){
			output += ( line[ i ] * ( n - i - 1 ) );
		}
		cout << output << endl;
	}

	return 0;
}