#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    while (n != 0) {
        int t[n];
        rep(i, n) cin >> t[i];

        long long int ans = 0;
        sort(t, t+n);
        rep(i ,n) {
            //dump(t[i]);
            ans += t[i] * (n-i-1);
            //dump(ans);
        }
        cout << ans << endl;
        cin >> n;
    }

    return 0;
}