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

int n;
int t[10005];
void solve(){
  for(int i=0;i<n;i++){
    cin >> t[i];
  }
  sort(t,t+n);
  unsigned long long wt=0,sum=0;
  for(int i=0;i<n-1;i++){
    wt += t[i];
    sum += wt;
  }
  cout << sum << endl;
}

int main(){
  while (cin >> n) {
    if(n == 0) break;
    solve();
  }
}