#include <iostream>
#include <algorithm>
#include <vector>

int main(){
  int n;
  while(std::cin>>n,n){
    std::vector<int> v;
    for(;n;n--){
      int i;
      std::cin>>i;
      v.push_back(i);
    }
    
    std::sort(v.begin(),v.end());
    
    std::vector<int>::iterator it = v.begin();
    long int wtime = 0,stime = 0;
    while(it!=v.end()){
      stime += wtime;
      wtime += (*it);
      it++;
    }
    std::cout<<stime<<std::endl;
  }
}