#include <iostream>
#include <vector>
#include <algorithm>	// require sort next_permutation count etc.

//#include <fstream>	// require freopen

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.milkshop", "r", stdin );
	int n;

	while (cin >> n && n ){
		vector <int> order (n);
		for (int i = 0; i < n; ++i ){
			cin >> order[i];
		} // end for
		sort (order.begin(), order.end() );
		int res = 0;

		for (int i = 1; i < n; ++i ){
			for (int j = 0; j < i; ++j ){
				res += order[j]; 
			} // end for
		} // end for
		cout << res << endl;
		order.clear();
	} // end while

		
	return 0;
}