#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;

int main() {
	for(int N; cin >> N, N;) {
		vector<int> v(N), w(N);
		for(int i = 0; i < N; i++) {
			cin >> v[i];
		}
		sort(v.begin(), v.end());
		partial_sum(v.begin(), v.end(), w.begin());
		cout << accumulate(w.begin(), w.end() - 1, 0) << endl;
	}
}