#include <bits/stdc++.h>
using namespace std;

int main(void){
  int n;
  while(cin >> n, n){
    vector<long long> cust;
    for(int i=0; i < n; i++){
      int tmp; cin >> tmp;
      cust.push_back(tmp);
    }
    sort(cust.begin(), cust.end());
    vector<long long> waiting(n, 0);
    for(int i=1; i < n; i++){
      waiting[i] = waiting[i-1] + cust[i-1];
    }
    long long ans = 0;
    for(int i=0; i < n; i++){
      ans += waiting[i];
    }
    cout << ans << endl;
  }
  return 0;
}