#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
	
	int n, ans;
	
	int a[20000];
	
	cin >> n;
	
	while(n != 0){
		
		for(int i = 0; i < n; i++){
			cin >> a[i];
		}
		
		sort(a, a + n);
		
		ans = 0;
		
		for(int i = 0; i < n; i++){
			ans += a[i] * (n - i - 1);
		}
		
		printf("%d\n", ans);
		
		cin >> n;
	}
	
	return 0;
}