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

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=0){
		vector<int> v;
		for(int i = 0; i < n; i++){
			int t;
			cin>>t;
			v.push_back(t);
		}
		sort(v.begin(),v.end());
		
		int sum=0;
		int wait=0;
		for(int i = 0; i < n-1; i++){
			wait+=v[i];
			sum+=wait;
		}
		cout<<sum<<endl;
	}

	return 0;
}