#include <iostream>
#include <algorithm>

using namespace std;

int main(void)
{
	int n;
	while (cin >> n, n){
		long long t[n];
		for (int i = 0; i < n; i++){
			cin >> t[i];
		}

		sort(t, t + n);
		for (int i = 0; i < n-1; i++){
			t[i+1] += t[i];
		}
		long long ret = 0;
		for (int i = 0; i < n-1; i++){
			ret += t[i];
		}
		cout << ret << endl;
	}

	return 0;
}