#include <iostream>
#include <vector>
#include <algorithm>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<long long> a;
		rep(i,n)
		{
			int t;
			cin >> t;
			a.push_back(t);
		}
		sort(a.begin(),a.end());

		long long sum = 0;
		vector<long long> time;
		long long count = 0;
		rep(j,n-1)
		{
			count += a[j];
			time.push_back(count);
		}
		rep(j,time.size())
		{
			sum += time[j];
		}

		cout << sum << endl;
	}
	
	return 0;
}