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

int main()
{
	int n, i, t, total;
	multiset<int> ms;
	multiset<int>::iterator it;


	while (cin>>n, n) {
		ms.clear();
		for (i = 0; i < n; i++) {
			cin>>t;
			ms.insert(t);
		}
		t = total = 0;
		for (it = ms.begin(); it != ms.end(); it++) {
			t += *it;
			total += t;
		}
		cout<<total-t<<endl;
	}

	return 0;
}