#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		int *c = new int[n];
		for (int i = 0; i < n; i++)
			cin >> c[i];
		sort(c, c + n);
		long long ans = 0;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < i; j++)
				ans += c[j];
		cout << ans << endl;
		delete[] c;
	}
	return 0;
}