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

int main(){

  int n,a[10010],b[10010],ans;

  while(cin >> n, n){

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

    sort(a,a+n);

    ans = 0;

    for(int i=0;i<n-1;i++){
      ans += a[i];
      b[i] = ans;
    }

    ans = 0;

    for(int i=0;i<n-1;i++) ans += b[i];

    cout << ans << endl;

  }
}