#include <iostream>
using namespace std;

namespace MyAlgorithm{

void swap( int* a, int* b ){
	int t = *a;
	*a = *b;
	*b = t;
}

void toggle( int* a, const int n )
{
	int t = a[ 0 ];
	for( int i = 0; i < n - 1; ++i ){
		a[ i ] = a[ i + 1 ];
	}
	a[ n - 1 ] = t;
}

void sort( int* a, const int n )
{
	if( n < 2 ){
		return;
	}
	if( n == 2 ){
		if( a[ 0 ] > a[ 1 ] ){
			swap( &a[ 0 ], &a[ 1 ] );
		}
		return;
	}

	int ref = a[ 0 ];
	int index1 = 1, index2 = n-1;
	while( index2 - index1 > 0 ){
		if( a[ index1 ] <= ref ){
			++index1;
			continue;
		}
		if( a[ index2 ] >= ref ){
			--index2;
			continue;
		}
		swap( &a[ index1 ], &a[ index2 ] );
	}
	sort( a + 1, index1 );
	sort( a + index1, n - index1 );

	toggle( a, index1 );
}

}//namespace MyAlgorithm

int main()
{
	int n;

	while( cin >> n && n ){
		int* line = new int[ n ]();
		for( int i = 0; i < n; ++i ){
			cin >> line[ i ];
		}
		MyAlgorithm::sort( line, n );
		int output = 0;
		for( int i = 0; i < n - 1; ++i ){
			output += ( line[ i ] * ( n - i - 1 ) );
		}
		cout << output << endl;
	}

	return 0;
}