#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;
const double PI=3.14159265359;

signed main(){
  int n;
  while(cin>>n,n){
    vector<int> t(n);
    rep(i,n)cin>>t[i];
    sort(all(t));
    vector<int> wait(n+5);
    wait[0]=0;
    rep(i,n+1)wait[i+1]=wait[i]+t[i];
    rep(i,n)wait[i+1]+=wait[i];
    cout<<wait[n-1]<<endl;
  }
  return 0;
}