#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
typedef long long ll;
using namespace std;
int main(void){
  int n;
  while(cin>>n,n){
    vector<ll> c(n);
    for(int i=0;i<n;++i) cin>>c[i];
    sort(c.begin(),c.end());
    ll a,b;a=b=0;
    for(int i=0;i<n;++i){
    	a+=b;
    	b+=c[i];
    }
    cout<<a<<endl;
  }
  return 0;
}