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

int main(){
	int n;
	while(cin >> n){
		int count = 0;
		if(n == 0) break;
		vector<int> nums;
		for(int i = 0; i < n; i++){
			int t;
			cin >> t;
			nums.push_back(t);
		}
		sort(nums.begin(), nums.end());
		for(int i = 1; i < nums.size(); i++){
			count += nums[nums.size() - 1 - i] * i;
		}
		cout << count << endl;
	}
	return 0;
}