#include <iostream>
#include <string>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define mp makepair
#define pb push_back
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main(){
	ull n,m,sum,route;
	vector<ull> v;
	while(cin >> n && n){
		v.clear();
		sum = route = 0;
		rep(i,n){
			cin >> m;
			v.pb(m);
		}
		sort(v.begin(),v.end());
		rep(i,n){
			sum += route;
			route += v[i];
		}
		cout << sum << endl;
	}
}