#include <bits/stdc++.h>

using namespace std;

int TimeOfPerson[10000];

void solve(int n) {
	long long int sum, now;

	sum = now = 0;
	for (int i = 0; i < n; i++) {
		now += TimeOfPerson[i];
		sum += now;
	}
	cout << sum << endl;
}

int main() {
	int n;

	while (cin >> n, n) {
		memset(TimeOfPerson, 0, sizeof(TimeOfPerson));
		for (int i = 0; i < n; i++) {
			cin >> TimeOfPerson[i];
		}
		sort(TimeOfPerson, TimeOfPerson + n);
		solve(n-1);
	}

	return 0;
}
