#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
  int TIME[11111],sum[11111],ret;
  int n;
  while(1){
    cin >> n;
    if(!n)break;
    memset( TIME , 0 , sizeof(TIME) );
    memset( sum , 0 , sizeof(sum) );
    for(int i=0;i<n;i++){
      cin >> TIME[i];
    }
    sort( TIME , TIME + n );
    ret = 0;
    sum[0] = 0;
    for(int i=1;i<n;i++){
      sum[i] = TIME[i-1] + sum[i-1];
      ret += sum[i];
    }
    cout << ret << endl;
  }
}