#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

signed main(){
	int n,t[10000];
	while(cin >> n,n){
		for(int i = 0;i < n;i++) cin >> t[i];
		sort(t,t + n,greater<int>());
		int res = 0;
		for(int i = 0;i < n;i++){
			res += t[i] * i;
		}
		cout << res << endl;
	}
	return 0;
}