#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	int i = 0;
	int t[256];
	int sum = 0;
	
	cin >> n;
	
	while (1){
		cin >> t[i];
		if (t[i] == 0){
			break;
		}
		i++;
	}
	
	sort(t, t + n);
	i = 0;
	
	while (i < n - 1){
		sum += t[i];
		t[i + 1] += t[i];
		i++;
	}
	
	cout << sum << endl;
	
	return (0);
}