#include <cstdio>

using namespace std;

int main()
{
	int n;
	int time[10000];
	int tmp;
	int wait_time;
	
	while (1){
		wait_time = 0;
		tmp = 0;
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		for (int i = 0; i < n; i++){
			scanf("%d", &time[i]);
		}
		
		for (int i = 0; i < n - 1; i++){
			for (int j = 0; j < n - i - 1; j++){
				if (time[j] > time[j + 1]){
					tmp = time[j];
					time[j] = time[j + 1];
					time[j + 1] = tmp;
				}
			}
		}
		//for (int i = 0; i < n; i++){
		//	printf("time[%d]=%d\n", i, time[i]);
		//}
		
		tmp = 0;
		
		for (int i = 0; i < n - 1; i++){
			tmp += time[i];
			wait_time += tmp;
			//printf("tmp=%d\n", tmp);
		}
		
		printf("%d\n", wait_time);
	}
	
	return (0);
}