#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<map>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1e13
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define MOD 1000000007

int main(){


    int n;
    while(cin >> n,n){
        ll count = 0;
        vector<ll> a(n),b(n,0);

        REP(i,n){
            cin >> a[i];
        }
        VSORT(a);

        b[0] = 0;
        for(int i = 1;i < n;i++){
            b[i] = b[i-1]+a[i-1];
        }
        REP(i,n){
            count += b[i];
        }
        cout << count << endl;
    }
    return 0;
}

