#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main(void){
  int n;
  while(cin>>n,n){
    vector<int> c(n),s(n);
    for(int i=0;i<n;++i) cin>>c[i];
    sort(c.begin(),c.end());
    for(int i=0;i<n;++i) s[i]=accumulate(&c[0],&c[i],0);
    cout<<accumulate(s.begin(),s.end(),0)<<endl;
  }
  return 0;
}