#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	vector<int> data;
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		data.clear();
		REP(i,n){
			int tmp;
			cin >> tmp;
			data.pb(tmp);
		}
		sort(All(data));
		ll int sum = 0;
		ll int ans = 0;
		REP(i,data.size()-1){
			sum += data[i];
			ans += sum;
		}
		cout << ans << endl;
 	}

 	return 0;
}