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

int main() {
	while(1) {
		int n, t[10001];
		long long sum_time = 0, wait_time = 0;
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++)
			cin >> t[i];
		sort(t, t + n);
		for (int i = 1; i < n; i++) {
			wait_time += t[i - 1];
			sum_time += wait_time;
		}
		cout << sum_time << endl;
	}
}
