#include<iostream>
using namespace std;
int main() {
	int a[10000], x, y, n, c;
	c = 0;
	while (1) {
		cin >> n;
		if (n == 0) { break; }
		for (int k = 0; k < n; k++) {
			cin >> a[k];
		}
		for (int j = 0; j < n; j++) {
			for (int i = 0; i < n -1; i++) {
				if (a[i] > a[i + 1]) {
					x = a[i];
					y = a[i + 1];
					a[i] = y;
					a[i + 1] = x;
				}
			}
		}
		for (int k = 0; k < n; k++) {
			c = c + a[k] * (n - (k + 1));
		}
		//cout << a[0] << a[1] << a[2] << a[3] << a[4] << endl;
		cout << c << ' ';
		c = 0;
	}
	return 0;
}