#include<stdio.h>
#include<algorithm>
int main(void)
{
	int n, a[10000],i,v;
	while(scanf("%d",&n),n)
	{
		for(i = 0; i < n; ++i)
			scanf("%d", &a[i]);
		std::sort(a, a+n);

		v = 0;
		for(i = 0; i < n; ++i)
		{
			v += a[i]*(n-1-i);
		}
		printf("%d\n",v);
	}
	return 0;
}