#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
	
	int guest[10001], n;
	int time = 0,time_sum = 0,i;
	
	while(scanf("%d", &n), n != 0){
	for(i = 0; i < n; i++) scanf("%d", &guest[i]);
	guest[i++] = 0;
	sort(guest, guest+i);
	
	for(i = 1; i < n; i++){
		time = time+guest[i];
		time_sum += time;
	}
	
	printf("%d\n", time_sum);
	}
	return(0);
}