#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n=0;
    while(cin>>n,n){
        int people[n];
        for(int i=0;i<n;i++)cin>>people[i];
        sort(people,people+n);
        long long int ans=0,now=0;
        for(int i=0;i<n;i++){
            ans+=now;
            now+=people[i];
        }
        cout<<ans<<endl;
    }
}