#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>

using namespace std;

string code[200];



int main(){
    int n;
    while(cin>>n){
        if(n==0)break;
        int customer[10001]={0};
        for(int i=0; i<n; i++){
            cin>>customer[i];
        }
        
        
        int ret=60*10000;
        /*
        do{
            int time=0;
            int temp=0;
            for(int i=1; i<n; i++){
                time=customer[i]+time;
                temp+=time;
            }
            
            ret=min(ret,temp);
        }while(next_permutation(customer,customer+n));
        */
        
        sort(customer,customer+n);
        
        
        int time=0;
        int temp=0;
        for(int i=0; i<n-1; i++){
            time=customer[i]+time;
            temp+=time;
        }
        cout<<temp<<endl;
    }
    
    
    
}