import std.stdio,std.string,std.conv,std.array;

int main()
{
	while(true)
	{
		int n = readln.chomp.to!int;
		if(n == 0) break;

		int a[];
		foreach(i;0..n) a ~= readln.chomp.to!int;
		
		a.sort;

		long sum = 0,count = 0;
		long time[];

		foreach(i;0..n-1)
		{
			count += a[i];
			time ~= count;
		}

		foreach(i;0..time.length)
		{
			sum += time[i];
		}

		sum.writeln;

	}
	return 0;
}