#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        long long need_time[10100]={0},total_time[10100]={0},total=0;
        for(int i=0;i<n;i++){
            cin>>need_time[i];
        }
        sort(need_time,need_time+n);
        for(int i=1;i<n;i++){
            total_time[i]=need_time[i-1]+total_time[i-1];
            total+=total_time[i];
        }
        cout<<total<<endl;
    }
    return 0;
}