#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

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

int main() {
  int n;
  while(cin >> n, n) {
    vector<int> a(n);
    REP(i,n)
      cin >> a[i];
    sort(ALL(a));
    int sum = 0, ans = 0;
    REP(i,n) {
      ans += sum;
      sum += a[i];
    }
    cout << ans << endl;
  }
}