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

using namespace std;

int main(void){
  while( true ){
    int n;
    long long int ans = 0;
    long long int sumWait = 0;
    vector<int> vwait;

    cin >> n;
    if(n == 0){
      break;
    }

    for(int i = 0; i < n; i++){
      int tmp;
      cin>>tmp;
      vwait.push_back(tmp);
    }

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

    for(int i = 0; i < n-1; i++){
      ans += sumWait = vwait[i] + sumWait;
    }

    cout<<ans<<'\n';

  }
  return 0;
}