#include <iostream>
#include <set>
using namespace std;
int main()
{
  for(;;){
    int n,i,j;
    cin >> n;
    if(n==0) break;
    multiset<int> s;
    for(i=0;i<n;i++){
      cin >> j;
      s.insert(j);
    }
    multiset<int>::iterator it = s.begin();
    i = j = 0;
    while(it != s.end()){
      j += i;
      i += (*it);
      it++;
    }
    cout << j << endl;
  }
  return 0;
}