#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

vector<int> kyaku;

int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		
		kyaku.clear();
		
		for(int i=0;i<n;i++){
			int t;
			cin>>t;
			kyaku.push_back(t);
		}
		sort(kyaku.begin(),kyaku.end());
		ll ans=0;
		vector<int> mati;
		mati.push_back(0);
		for(int i=0;i<n-1;i++){
			mati.push_back(mati[i]+kyaku[i]);
			ans+=mati[i+1];
		}
		
		
		cout<<ans<<endl;
	}
}