#include <stdio.h>
#include <algorithm>

using namespace std;

int main(int argc, char const* argv[])
{
	int n;
	int a[100000];

	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}

		for (int i = 0; i < n; i++){
			scanf("%d", a + i);
		}

		sort(a, a + n);
		reverse(a, a + n);
		
		long long ans = 0;
		for (int i = 0; i < n; i++){
			ans += a[i] * i;
		}

		printf("%lld\n", ans);
	}

	return 0;
}