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

int main(){
 

  while(1){
    vector<int> t;
    int n,a;
    cin >> n;
    if(n==0) break;

    for(int i = 0; i < n ; i++){
      cin >> a;
      t.push_back(a) ;
    }
    std::sort(t.begin(),t.end());

    long long mati[10010]={0};
    long long ans=0;

    for(int i = 1; i < n; i++){
      mati[i] = mati[i-1] + t[i-1];
      //   cout << mati[i] << " ";
      ans += mati[i];
    }
    cout << ans << endl;
  }
  return 0;
}