#include <iostream>
#include <algorithm>

using namespace std;

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

    int data[n];
    for(int i = 0; i < n; i++) {
      cin >> data[i];
    }
    sort(&data[0], &data[n]);

    unsigned int ans = 0;
    for(int i = 0; i < n; i++) {
      ans += data[i] * (n - i - 1);
    }

    cout << ans << endl;
  }
}