#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    while(true){
    int n,sum=0;
    cin >> n;
        if(n==0) break;
    int ar[n];
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        ar[i]=a;
    }
    sort(ar,ar+n);
    for(int j=0;j<n;j++){
        sum += j*ar[n-1-j];
    }
    
        cout << sum << endl;
    }
    
}