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

int main(){

	int n;
	while (std::cin >> n, n){

		long long res = 0;

		std::vector<int>v(n), p(n, 0);

		for (int i = 0; i < n; i++)std::cin >> v[i];

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

		for (int i = 1; i < n; i++)p[i] = p[i - 1] + v[i - 1];

		for (int i = 0; i < p.size(); i++)res += p[i];

		std::cout << res << std::endl;
	}

	return 0;
}