#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
int n;
while(cin>>n,n){
vector<long long int>in;
rep(i,n){
long long int in1;
cin>>in1;
pb(in,in1);
}
sort(all(in));
long long int sum=0;
rep(i,n-1)
sum+=in[i]*(n-i-1);
cout<<sum<<endl;
}
}