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

int main()
{
  int n,c;
  long long wait,sum;
  multiset<int> customer;
  multiset<int>::iterator it;
  while(cin>>n,n){
    customer.clear();
    while(n-->0){cin>>c;customer.insert(c);}
    wait=sum=0;
    for(it=customer.begin();it!=customer.end();it++){
      wait+=*it;
      sum+=wait;
    }
    cout<<sum-wait<<endl;
  }
}