#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;

int d[16384];

int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		for (int i = 0; i < n; ++i)
			scanf("%d", d + i);
		sort(d, d + n);
		long long  ans = 0;
		long long  t = 0;
		for (int i = 1; i < n; ++i)
		{
			t += d[i-1];
			ans += t;
		}
		printf("%lld\n", ans);
	}

	return 0;
}