So let's think about this.. We payed 4M to buyout Manny from Temple. We then gave him a 5 year contract where he made 3.1M his first season and each year it increases. We now would have to Buyout the rest of Mannys contact. Let's say 12-15M. Now we will have to buy out our next HC unless you want a failed HC that was just fired or another first time HC. We now have to also give our new HC around 3.5-4M per year. So let's say we hire Cristobal, it would likely cost at minimum 25M to Buyout everyone and pay his first year salary.
Your final number is close to what I came up with, but how you get there is a bit off. Here's my best guesstimate.
First, the $4M to Temple is a sunk cost. Keep Diaz, boot Diaz, fold the program... that money was spent. Take it out of the equation.
Assuming in this fantasy Diaz is fired at the end of the season, he likely has $13M to $14M remaining on the contract (my best guess is the number is 13.4, and the "slight" yearly increases cited by the Herald are $100K/year, which is similar to Cristobal's yearly raises in his extension). But even that figure can be (and often is) negotiated down some, reasonably in the neighborhood of $10M to $11M. And many coaches with minimal experience have clauses included in their contracts that only allow them to recover a % of their remaining $$ in a buyout (Cristobal, for example, only gets 60% of his remaining cash if terminated). Whether such a clause exists in Diaz's contract is an unknown (though if there isn't a 50-60% buyout in the contract, I'd argue that's just further evidence that Blake James is a complete moron in over his head).
Further assuming Cristobal is the guy and he's coming, Cristobal happens to be under contract through 2024 (making $2.6M this year with equal increases up to $3M his final year). His buyout is $9M if he leaves before 1/14/2020, then $8M, $5M, $3M, and finally $2M (in each subsequent year). Even if all of this was going to happen, I would guess UM waits until 1/15 to save themselves $1M (but our AD and BOT have done much dumber things in the past).
Assuming $3.5M in year 1 salary for Cristobal, we're at $21.5M to $22.5M (buyout Diaz, pay Cristobal's buyout, and pay Cristobal's 2020 salary), and that's assuming UM can only get about a 25% discount on Diaz's buyout and doesn't have more favorable contract terms (again, knowing Blake James, I wouldn't be surprised either way). Assuming a 50% buyout clause, the total is $18M to $18.5M.