#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int i, n;
    while(cin >> n, n){
        int m[10000] = {'\0'};
        for(i = 0; i < n; i++){
            cin >> m[i];
        }
        long long sum = 0;
        int j = 0;
        sort(m, m+n);
        i--;
        while(m[j]){
            sum += m[j++] * i--;
        }
        cout << sum << endl;
    }
}