
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

long long n,a[10002];

void solve() {
  sort(a,a+n);
  long long cur=0,sum=0;
  rep(i,n-1) {
    cur+=a[i];sum+=cur;
  }
  printf("%lld\n",sum);
}

int main() {
  while(cin>>n,n) {
    rep(i,n) cin>>a[i];
    solve();
  }
  return 0;
}