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

int t[10001], ti;
int main()
{
  int n;
  while (cin >> n, n){
    ti = 0;
    for (int i = 0; i < n; i++){
      cin >> t[i];
    }
    sort(t, t + n);
    for (int i = 0; i < n; i++){
      int num = t[i];
      t[i] = ti;
      ti += num;
    }
    cout << accumulate(t, t + n, (long long)0) << endl;
  }
  return (0);
}