#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int main() {
	int n;
	while (cin >> n, n) {
		vector<int> v(n);
		REP(i, n) scanf("%d", &v[i]);
		sort(v.begin(), v.end());
		
		long long  ans = 0, tmp = 0;
		REP(i, n) {
			ans += tmp;
			tmp += v[i];
		}
		cout << ans << endl;
	}
	return 0;
}