#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
 int n;
 while (cin >> n, n) {
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  long long cnt = 0;
  for (int i = 0; i < n - 1; i++) {
    cnt += v[i] * (n - 1 - i);
  }
  cout << cnt << endl;
 }
}