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

int main(){
  int i,n,m,j;
  long long ans;
  while(1){
    vector<int> v;
    cin >> m;
    if(m == 0) break;

    for(i=0;i<m;i++){
      cin >> n;
      v.push_back(n);
    }

    sort(v.begin(), v.end());

    ans = j = 0;
    for(i=v.size()-1;i>0;i--){
      ans += (long long)v[j] * i;
      j++;
    }
    
    cout << ans << endl;
  }
  return 0;
}