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

int main(){
	unsigned int n,wait,sum,t;
	vector<unsigned int> milk;
	while(cin >> n && n){
		milk.clear();
		wait = sum = 0;
		for(int i=0;i<n;i++){
			cin >> t;
			milk.push_back(t);
		}
		sort(milk.begin(),milk.end());
		for(int i=0;i<n;i++){
			sum += wait;
			wait += milk[i];
		}
		cout << sum << endl;
	}
}