#include <iostream>
#include <algorithm>
#define N 10000
using namespace std;
int main(){
  int i,j,n,need[N],wait[N];
  long long sum;
  while(1){
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> need[i];
    }
    for(i=0;i<n;i++){
      for(j=1;j<n;j++){
	if(need[j]<need[j-1]) swap(need[j],need[j-1]);
      }
    }
    sum=0;
    wait[0]=0;
    for(i=1;i<n;i++){
      wait[i]=need[i-1]+wait[i-1];
      sum+=wait[i];
    }
    cout << sum << endl;
  }
  return 0;
}