#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#define  N   10000
using namespace std;
int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0) break;
		vector<int> time;
		int sum[N],result=0;

		for(int i=0;i<n;i++){
			int t;
			cin>>t;
			time.push_back(t);
		}
		sort(time.begin(),time.end());

		sum[0]=0;
		for(int i=0;i<n-1;i++){
			sum[i+1] = time[i]+sum[i];
		}
		for(int i=0;i<n;i++){
			result += sum[i];
		}
		cout<<result<<endl;
	}

	return 0;
}