#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int divideByPivot(int A[],int left,int right,int pivot){
	int start = left,end = right;
	while(true){
		while(A[start] < pivot && start <= right) start++;
		while(A[end] >= pivot && end >= left) end--;
		if(start >= end){
			break;
		}else{
			swap(A[start],A[end]);
		}
	}
	for(int i = left; i<= right; i++){
		if(A[i] >= pivot) return i;
	}
	return -1;	//must not reach here
}

int findPivot(int A[],int left,int right){
	int pivot_candidate = A[left];
	for(int i = left + 1; i <= right; i++){
		if(A[i] != pivot_candidate)
			return (A[i] > pivot_candidate)?A[i]:pivot_candidate;
	}
	return -1;
}


void quickSort(int A[],int left,int right){
	int pivot = findPivot(A,left,right);
	if(pivot != -1){
		int div_point = divideByPivot(A,left,right,pivot);
		if(left+1 < div_point)	quickSort(A,left,div_point-1);
		quickSort(A,div_point,right);
	}
}


int main(){

	int n,array[10000];
	long long sum;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		sum = 0;

		for(int i = 0; i < n; i++){
			scanf("%d",&array[i]);
		}

		quickSort(array,0,n-1);

		for(int i = 0; i <= n-2; i++){
			sum += (n-1-i)*array[i];
		}

		printf("%lld\n",sum);
	}

	return 0;
}