#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <bitset>
using namespace std;
 
 
const double EPS = 1e-9;
 
int main(){

	priority_queue<int, vector<int>, greater<int> > pq;
	int n;
	cin >> n;
	while(cin >> n, n){
		pq.push(n);
	}
	int wt = 0;
	while(!pq.empty()){
		wt += pq.top()*(pq.size()-1);
		pq.pop();
	}

	cout << wt << endl;
 
    return 0;
}