#include <iostream>
using namespace std;

int main(){
  int data[10010];
  while(1){
    int n; cin >> n;
    if( n == 0 ) break;
  
    int i,j;
    for( i = 0; i < n; i++ )cin >> data[i];
    
    for( i = 0; i < n; i++ ){
      for( j = 0; j < n-1; j++ ){
	if( data[j] > data[j+1]) swap( data[j],data[j+1] );
      }
    }
   
    int time = 0,total = 0;
    
    for( i = 1; i < n; i++ ){
      total += data[i-1];
      time += total;
    }
    cout << time  << endl;
  }
  
  return 0;
}