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

int main() {
	int n;
	while(cin>>n,n!=0){
		int no[n];
		long long int sum=0,nsum=0;
		for(int i=0;i<n;i++)cin>>no[i];
		sort(no,&no[n]);
		for(int i=0;i<n;i++){
			if(i!=0)nsum+=sum;
			sum+=no[i];
		//cout<<no[i]<<" "<<sum<<" "<<nsum<<endl;
		}
		cout<<nsum;
		
	}
	return 0;
}