#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  while (true) {
    cin >> n;
    if (n == 0)
      break;
    int time[10000], t = 0;
    for (int i = 0; i < n; i++)
      cin >> time[i];

    sort(time, time + n);
    for (int i = 0; i < n; i++) {
      int bef = time[i];
      time[i] = t;
      t += bef;
    }

    cout << accumulate(time, time + n, 0) << endl;
  }
  return 0;
}