#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
  int n;
  vector<int> vec;
  int sum;

  while (scanf("%d", &n), n){
    for (int i=0; i<n; i++){
      int x;
      scanf("%d", &x);
      vec.push_back(x);
    }
    sort(vec.begin(), vec.end());
    sum = 0;
    for (int i=0; i<n-1; i++){
      sum += vec[i]*(n-1-i);
    }
    printf("%d\n", sum);
  }

  return 0;
}