#include <iostream>
#include <queue>
#include <vector>
#include <functional>

using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		priority_queue< int, vector<int>, greater<int> > pq;
		int a;
		for (int i = 0; i < n; i++) {
			cin >> a;
			pq.push(a);
		}
		int counter = 0;
		int counter2 = 0;
		for (int i = 0; i < n-1; i++) {
			counter2 += pq.top();
			pq.pop();
			counter += counter2;
		}
		cout << counter << endl;
	}
	return 0;
}