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

int main()
{
	long long int n,sum,S,temp;
	priority_queue<int, vector<int>,greater<int> > que;
	while(cin >> n, n){
		S = 0;
		sum = 0;
		for(int i = 0;i < n;i++){
			cin >> temp;
			que.push(temp);
		}
		while(!que.empty()){
			sum += S;
			S +=  que.top();
			que.pop();
		}
		cout << sum << endl;
	}
	return 0;
}