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

typedef long long ll;

int main()
{
	ll n;
	while( std::cin >> n, n )
	{
		std::vector<ll> v;

		for( int i = 0; i != n; ++i )
		{
			ll t;
			std::cin >> t;
			v.push_back( t );
		}

		std::sort( v.begin(), v.end() );

		ll ans = 0, prv = 0;
		for( int i = 0; i != n; ++i )
		{
			ans += prv;
			prv += v[i];
		}

		std::cout << ans << std::endl;
	}

	return 0;
}