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

int main() {
	while (1) {
		int a;
		cin >> a;
		if (a == 0)break;
		vector<int>s(0);
		for (int b = 0; b<a; b++) {
			int c;
			cin >> c;
			s.push_back(c);
		}
		sort(s.begin(), s.end());
		int q=0;
		for (int g = 0; g < s.size() - 1; g++) {
			q += s[g] * (s.size() - g - 1);
		}
		cout << q << endl;
	}
}