/*
	AOJ_0112: A Milk Shop
*/
#include	<iostream>
#include	<vector>
#include	<algorithm>

using namespace std;

int main(void) {
	int n, buf;
	long long int sum;
	while (1) {
		vector<int> order;
		sum = 0;
		
		cin >> n;
		if (n == 0) { break; }

		for (int i = 0; i < n; i++) {
			cin >> buf;
			order.push_back(buf);
		}
		sort(order.begin(), order.end());
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < i; j++) {
				sum += order[j];
			}
		}
		cout << sum << endl;
	}
}