#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){int n,i,t;for(long int ans;cin>>n,n;cout<<ans<<endl){vector<int> m;for(ans=i=0;i++<n;m.push_back(t))cin>>t;sort(m.begin(),m.end());for(i=1;i<n;i++)ans+=m[i-1]*(n-i);}}