#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char const* argv[])
{
	int data[10000];
	unsigned int answer[10000];

	int n;
	while( cin >> n && n != 0 ){
		for( int i = 0;i < 10000;i++ ){
			data[i] = 0;
			answer[i] = 0;
		}
		for( int i = 0;i < n;i++ ) cin >> data[i];
		sort( data, data + n );
		answer[0] = 0;
		for( int i = 1;i < n;i++ ) answer[i] = data[i - 1] + answer[i - 1];
		unsigned a = 0;
		for( int i = 0;i < n;i++ ) a += answer[i];
		cout << a << endl;
	}

	return 0;
}