#include <iostream>
#include <algorithm>

int main()
{
	int n;
	while (std::cin >> n) {
		if (n==0) break;
		int* A = new int[n];
		for (int i=0; i<n; i++) std::cin >> A[i];
		std::sort(A, A+n);
		unsigned long long sum = 0;
		for (int i=0; i<n-1; i++) sum += (unsigned long long)((n-i-1) * A[i]);
		std::cout << sum << std::endl;
		delete[] A;
	}
	
	return 0;
}

