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

int main() {
	int n;

	while(std::cin >> n, n) {
		std::vector<int> v;
		for(int i = 0; i < n; i++) {
			int tmp;
			std::cin >> tmp;
			v.push_back(tmp);
		}

		std::sort(v.begin(), v.end());

		long long ans = 0;
		for(int i = 0, wait = 0; i < v.size(); i++) {
			ans += wait;
			wait += v[i];
		}

		std::cout << ans << std::endl;
	}

	return 0;
}