#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	while(cin>>n,n) 
	{
		int in[n];
		for(int i = 0; i < n; ++i)
		{
			cin>>in[i];
		}
		int ans=0,sum=0;
		sort(in,in+n);
		for(int i = 1; i < n; ++i)
		{
			sum+=in[i-1];
			ans+=sum;
		}
		cout<<ans<<endl;
	}
  return 0;
}