#include <bits/stdc++.h>
#define MAX_N 10000
#define INF 100
using namespace std;
typedef long long ll;
int n;
ll data[MAX_N + 1];

ll calcSum() {
    ll sum = 0, wait = 0;
    for(int r = 0; r < n; r++) {
        sum += wait;
        wait += data[r];
    }
    return(sum);
}

void solve() {
    sort(data, data+n);
    printf("%lld\n", calcSum());
}

int main(void) {
    while(cin >> n, n) {
        memset(data, INF, sizeof(data));
        for(int r = 0; r < n; r++) {
            cin >> data[r];
        }
        solve();
    }
    return(0);
}