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

using namespace std;

vector<int> m;

int main() {
	int N;
	while (cin >> N, N) {

		m = vector<int>(N);
		for (int i = 0; i < N; i++) {
			cin >> m[i];
		}

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

		int count = 0;
		int ans = 0;

		for (int i = 1; i < N; i++) {
			count += m[i - 1];
			ans += count;
		}

		cout << ans << endl;

	}
	return 0;



}
