#include<iostream>
#include<algorithm>
using namespace std;

int func(int dt[],int num){
	unsigned long long int c=num;
	unsigned long long int time=0;
	for(int i=0;i<c-1;i++){
		time+=(c-(i+1))*dt[i];
	}
	return time;
}

int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0)break;
		unsigned long long int cost[n];
		unsigned long long int ans=0;
		for(int i=0;i<n;i++){
			cin>>cost[i];
		}
		sort(cost,cost+n);
		ans=func(cost,n);
		cout<<ans<<endl;
	}
	return 0;
}