#include<iostream>
#include<algorithm>

using namespace std;

int main(){

  int in;
  while(cin >> in && in){
    long long  sum = 0, now = 0;
    int data[in];
    for(int i = 0; i < in; i++) cin >> data[i];
    sort(data,data+in);
    for(int i = 0; i < in; i++){
      sum += now;
      now += data[i];
    }
    cout << sum << endl;
  }
  return 0;
}