#include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

int n;
	while( cin >> n){

		if(n==0 || cin.eof()) break;
		vector<int> nb(n,0);
		rep(i, n) cin >> nb[i];
		sort(nb.begin(), nb.end());
		long long ans=0;
		rep(i,n-1) ans += nb[i] * (n-1-i);
		cout << ans << endl;
	}

	return 0;
	
}