#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(void){
	
	unsigned i,n,sum,temp;
	
	vector<unsigned> cus;
	vector<unsigned> wait;
		
	while(cin>>n,n){
		
		cus.clear();
		wait.clear();
		i=sum=temp=0;
			
		for(int k=0;k<n;k++){
			cin>>i;
			if(k>1000||n==0){
				break;
			}
			cus.push_back(i);
		}
	
		sort(cus.begin(),cus.end());

		for(unsigned k=0;k<cus.size();k++){
			for(unsigned m=0;m<k;m++){
				temp=temp+cus[m];
			}
			wait.push_back(temp);
			temp=0;
		}
	
		for(unsigned k=0;k<wait.size();k++){
			sum=sum+wait[k];
		}
		cout<<sum<<endl;
	}
}