#include <cstdio>
#include <algorithm>

using namespace std;

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