#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main(void){
  long long n;
  while(cin>>n,n){
    vector<long long> bef(n,0);
    vector<long long> vec(n);
    for(long long i = 0 ; i < n ; i ++){
      cin>>vec[i];
    }
    sort(vec.begin(),vec.end());
    long long ans;
    ans=0;
    //cout<<vec[0]<<endl;
    for(long long i = 1 ; i < n ; i++){
      bef[i] += vec[i-1] + bef[i-1];
      //cout<<bef[i]<<" "<<vec[i]<<endl;
      ans+=bef[i];
    }
    cout<<ans<<endl;
  }
}