#include <cstdio>
#include <algorithm>

using namespace std;

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