#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;





int main(){


	vector<int> t(10001, 61);
	int p;
	int i;
	vector<int> total(10001, 0);
	int matu = 0;


	while (1){

		for (i = 0; i <= 10000; i++){
			t[i] = 61;
		}
		for (i = 0; i <= 10000; i++){
			total[i] = 0;
		}
		matu = 0;

		cin >> p;
		if (p == 0){
			break;
		}

		for (i = 0; i < p; i++){
			cin >> t[i];
		}
		sort(t.begin(), t.begin() + i - 1);


		for (i = 1; i < p; i++){
			total[i] = t[i - 1] + total[i - 1];
		}

		for (i = 0; i < p; i++){
			matu += total[i];
		}

		cout << matu << endl;

		
	}

}