a(n) = {
	my(p); 
	if(n < 7, 
		2 * n - 4
	, 
		p = precprime(n - 2); 
		if(n - p <= 4,
			(n - p) * p
		,
			my(found = p * A056240(n - p)[1], pfound = p); 
			while(found / p > n - p && p > 2,
				p = precprime(p - 1); 
				found = min(found, A056240(n - p)[1] * p);
				
			); found
			
			
		)
	)
}

A056240(n) = {
	
	if(n <= 5, return([n, n - 2 * (n == 4)])); 
	my(p = precprime(n), found = p * (n - p));
	if(p == n, 
		return([p, p])
	,
		p = precprime(n - 2); 
		found = p * A056240(n - p)[1];
		while(found / p > n - p && p > 2, 
			p = precprime(p - 1); 
			
			found = min(found, A056240(n - p)[1] * p);
		); 
		[found, hpf(found)]  
	) 
}