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

int main() {
  int n = 0;
  long long timetowait = 0;
  while(cin >> n && n != 0){
  vector<int> vec(n,0);
  
  for(int i = 0; i < n; i++)	cin >> vec.at(i);
  
  sort(vec.begin(), vec.end());
  
  for(int i = 0; i < n; i++){
    timetowait += vec.at(i) * (n - 1 - i);
  }
  cout << timetowait << endl;
    timetowait = 0;
  }
}
