#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
	ll n;
	while (cin >> n, n) {
		vector<ll> v;
		for (ll i = 0; i < n; ++i) {
			ll a; cin >> a;
			v.push_back(a);
		}

		sort( v.begin(), v.end() );

		ll s = 0;
		for (ll i = 0; i < n-1; ++i)
			s += v[i] * (n-i-1);

		cout << s << endl;
	}
}