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

int main() {
  int n, t[10000];

  while(1) {
    cin >> n;
    if (n == 0) break;

    for (int i = 0; i < n; i++) cin >> t[i];

    sort(t, t+n);

    int tmp = 0, ans = 0;
    for (int i = 0; i < n-1; i++) {
      tmp += t[i];
      ans += tmp;
    }
    cout << ans << endl;
  }

}