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

int main(){
	int n,i,sum,wait;
	vector<int> w;
	while(cin>>n,n){
		w.assign(n,0);
		for(i=0;i<n;cin>>w[i],ut<<sum<<endl;++i);
		sort(w.begin(),w.end());
		for(sum=wait=0,i=0;i<n-1;wait+=w[i],sum+=wait,++i);
		co
	}
	return 0;
}