#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		int* ppl = new int[n];
		for(int i=0;i<n;i++){
			scanf("%d",ppl+i);
		}

		sort(ppl,ppl+n);
		int wait=0;
		int sum=0;
		for(int i=0;i<n-1;i++){
			wait += ppl[i];
			sum+=wait;
		}

		delete[] ppl;

		cout << sum << endl;
	}
}