#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int main()
{
    int n;
    while(cin >> n && n)
    {
        vector<int> t;
        int tt;
        REP(n){cin >> tt; t.push_back(tt);}
        
        int ans = 0;
        sort(all(t), greater<int>() );
        REP(n)for(int j = i + 1;j<n;j++) ans += t[j];

        //REP(n) cout <<i << ":"<< t[i]<< endl;

        cout << ans << endl;

    }

    return 0;
}