#include<iostream>
#include<set>
using namespace std;main(){for(long long n,w,s;cin>>n,n;cout<<s-w<<endl){multiset<int>c;multiset<int>::iterator i;for(;n-->0;c.insert(w))cin>>w;w=s=0;for(i=c.begin();i!=c.end();)s+=w+=*i++;}}