#include <bits/stdc++.h>
#define rep(i,n)for(ll i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<char, int>P;

int main() {
	ll n; 
	while (cin >> n, n) {
		vector<ll>v;
		rep(i, n) {
			ll t; cin >> t;
			v.push_back(t);
		}
		sort(v.begin(), v.end());
		ll cnt = 0;
		ll back = 0;
		for (ll i : v) {
			cnt += back;
			back += i;
		}
		cout << cnt << endl;
	}
	return 0;
}