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