#include <iostream>
#include <algorithm>

int main(){
  int kyaku[10000]={0};
  int n;
  while(std::cin>>n){
    if(!n)return 0;
    for(int i=0;i<n;i++){
      std::cin>>kyaku[i];
    }
    std::sort(kyaku,kyaku+n);
    int takingtime=0,before=0;
    for(int i=0;i<n-1;i++){
      before += kyaku[i];
      takingtime += before;
    }
    std::cout<<takingtime<<std::endl;
  }
}