#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef vector <int> VI;

int main() {
    int n;
    while ( cin >> n && n ) {
        VI A( n );
        for ( int i = 0; i < n; ++ i ) cin >> A[i];
        sort( A.begin(), A.end() );
        int n = A.size();
        int answer = 0;
        int w = 0;
        for ( int i = 0; i < n; ++ i ) {
            answer += w;
            w += A[i];
        }
        cout << answer << endl;
    }
    return 0;
}