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

int n;
int time_each[10010];
int main() {
  while(scanf("%d", &n), n) {
    vector<int> times;
    
    for (int i=0; i<n; i++) {
      int t;
      scanf("%d", &t);
      times.push_back(t);
    }
  
    sort(times.begin(), times.end());

    int wait_time = 0;
    for (int i=0; i<n-1; i++) {
      wait_time += times[i];
      time_each[i] = wait_time;
    }

    long long total_time = 0;
    for (int i=0; i<n-1; i++) {
      total_time += (long long)time_each[i];
    }
    
    printf("%lld\n", total_time);
    
  }
}