#include<stdio.h>
#include<algorithm>
int main()
{
	long long n,a[10000],i,r;
	while(scanf("%lld",&n),n)
	{
		for(i=0;i<n;++i)scanf("%lld",&a[i]);
		std::sort(a,a+n);
		for(i=r=0;i<n;++i)r+=a[i]*(n-i-1);
		printf("%lld\n",r);
	}
}