#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main(void){
  int n, t, sum;
  vector<pair<int, int> > v;

  while(cin >> n, n){
    for(int i=0; i<n; i++){
      cin >> t;
      v.push_back(make_pair(t, 0));
    }
    sort(v.begin(), v.end());

    for(int i=1; i<n; i++){
      v[i].second = v[i-1].first + v[i-1].second;
    }

    sum = 0;
    for(int i=0; i<n; i++){
      sum += v[i].second;
    }

    cout << sum << endl;
  }

  return 0;
}