#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define DEB 1
#define all(x) x.begin(), x.end()


int main(){
  
  int n;
  while(scanf("%d",&n),n){
    vector<int> v;
    rep(i,n){
      int t; scanf("%d",&t);
      v.push_back(t);
    }
    sort(all(v));
    long long ans = 0;
    long long time = 0;
    rep(i,n){
      ans += time;
      time += (long long)v[i];
    }
    printf("%lld\n",ans);
  }
  return 0;
}