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

int main() {
  long long int n,wait[10000],customer[10000],total;
  while(cin >> n) {
    if(n == 0) break;
    long long int wait[10000] = {0},customer[10000] = {0},total = 0;
    for(int i=0;i<n;i++) {
      cin >> customer[i];
    }

    sort(customer,customer+n);

    for(int i=0;i<n;i++) {
      if(i==0) {
        wait[i] = 0;
      }
      else {
        wait[i] = wait[i-1] + customer[i-1];
      }
      total += wait[i];
    }
    cout << total << endl;
  }
}