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

int main(){
	int n;
	while(cin >> n, n){
		vector<int> vi(n);
		for(int i = 0; i < n; i++){
			cin >> vi[i];
		}
		sort(vi.begin(), vi.end());
		long long ans = 0, sum = 0;
		for(int i = 0; i < n; i++){
			ans += sum;
			sum += vi[i];
		}
		cout << ans << endl;
	}
}