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

int main() {
  int n, t, a[10000];
  long long int s;
  while (cin >> n && n) {
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a, a+n);
    s = t = 0;
    for (int i=0; i<n-1; i++) {
      t += a[i];
      s += t;
    }
    cout << s << endl;
  }
  return 0;
}