#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
main(){
  int n,a[10000],i,s,t;
  while(1){
    cin >> n;
    if(n==0){
      break;
    }
    for(i=0;i<n;i++){
      cin >> a[i];
    }
    sort(a,a + n);
    for(i=0,s=0,t=0;i<n;i++){
      t=t+s;
      s=s+a[i];
    }
    cout << t << endl;
  }
}