#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<vector>
using namespace std;
int main(){
    int n;
    while(cin >> n,n){
        vector<long long> T;
        for(int i = 0; i < n; i++){
            int a;
            cin >> a;
            T.push_back(a);
        }
        sort(T.begin(),T.end());
        int now = 0;
        int ans = 0;
        for(int i = 1; i < n; i++){
            now += T[i-1];
            ans += now;
        }
        printf("%d\n",ans);
    }
	return 0;
}