#include <cstdio>
#include <algorithm>

using namespace std;

int main(void)
{
	int n, t[10000], ct, st[10000], sum_t;
	
	while (scanf("%d", &n),n != 0){
		ct = sum_t = 0;
		for (int i = 0; i < n; i++){
			scanf("%d", &t[i]);
		}
		
		sort (t, t + n);
		
		for (int i = 0; i < n; i++){
			ct += t[i];
			if (i < n - 1){
				st[i] += ct;
			}
		}
		
		for (int i = 0; i < n; i++){
			sum_t += st[i];
		}
		
		printf("%d\n", sum_t);
	}
	return (0);
}