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

int main(void)
{
    int n;
    unsigned int sum, wait;
    unsigned int milk[10000];
    
    while (1) {
        scanf("%d", &n);
        
        if (n == 0) break;
        
        for (int i = 0; i < n; i++){
            scanf("%d", &milk[i]);
        }
        
        sort(milk, milk + n);
        
        sum = 0;
        wait = 0;
        for (int i = 0; i < n; i++){
            sum += wait;
            wait += milk[i];
        }
        printf("%u\n", sum);
    }
}