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

int main()
{
	int i, n, t;
	std::vector<int> data;
	long long sum, result;

	while (1) {
		std::cin >> n;

		if (n == 0) return 0;

		for (i = 0; i < n; i++) {
			std::cin >> t;
			data.push_back(t);
		}

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

		for (i = 0, sum = 0, result = 0; i < data.size(); i++) {
			result += sum;
			sum += (long long)data[i];
		}

		std::cout << result << std::endl;
	}

	return 1;
}