#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

int main(){
    int n;
    while (cin >> n, n){
        vector<int> a(n);
        rep(i, n) cin >> a[i];
        sort(all(a));
        int ans = 0, s = 0;
        rep(i, n){
            ans += s;
            s += a[i];
        }
        cout << ans << endl;
    }
}