#include <iostream>
#include <algorithm>

using namespace std;

int arr[10000];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    while(true) {
        int N;
        cin >> N;
        if(!N) break;
        for(int i = 0; i < N; ++i) {
            cin >> arr[i];
        }
        sort(arr, arr+N);
        long long ans = 0;
        long long acc = 0;
        for(int i = 0; i < N; ++i) {
            ans += acc;
            acc += arr[i];
        }
        cout << ans << endl;
    }
    return 0;
}