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

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