# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>

using namespace std;

int main() {
	int n;
	while (cin >> n&&n != 0) {
		vector<int> milk;
		int a;
		for (int i = 0; i < n; i++) {
			cin >> a;
			milk.emplace_back(a);
		}
		sort(milk.begin(), milk.end());
		int j[10001];
		j[0] = 0;
		for (int i = 1; i < n; i++) {
			j[i] = milk[i-1] + j[i - 1];
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans += j[i];
		}
		cout << ans << endl;
	}
}