#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;

void QuickSort(vector<int>& vi,int begin,int end){
	int i=begin;
	int j=end;
	int pivot;
	pivot=vi[(begin+end)/2];
	while(1){
		while(vi[i]<pivot){++i;}
		while(vi[j]>pivot){--j;}
		if(i>=j) break;

		swap(vi[i],vi[j]);
		++i;
		--j;
	}
	if(begin<i-1){ QuickSort(vi,begin,i-1); }
	if(j+1<end){ QuickSort(vi,j+1,end); }
}

int main (){
	int n;
	while(cin >> n&&n){
		long long int ans=0;
		long long int result=0;
		vector<int> guest(n);
		for(int i=0; i<n; ++i){
			cin >> guest[i];
		}
		QuickSort(guest,0,guest.size()-1);
		/*for(int i=0; i<guest.size(); ++i){
			cout << guest[i] << "\n";
		}*/
		for(int i=0; i<guest.size(); ++i){
			result+=ans;
			ans+=guest[i];
		}
		cout << result << "\n";
	}
	return 0;
}