In the July/August 2021 issue of MIT Technology Review, there was a "logical hat" problem by Richard Hess in the Puzzle Corner. I noticed that it could be generalized. Here is the "next level" version of Hess's puzzle; once you solve it, you should see how to generalize it further. (The description below is self-contained; I recommend that you solve it before clicking on the link to see Hess's original puzzle.)
Alice, Bob, and Chris are honest perfect logicians. A referee places a hat on each of their heads. Each hat has a strictly positive integer (i.e., zero is not allowed) written on it, which the other two logicians can see but which the wearer cannot. One of these numbers is the sum of the other two (so for example, the three numbers could be 3, 7, 4, or another possibility is 6, 6, 12). Everything I've said so far is public knowledge.
Alice announces for all to hear, "I can't deduce the number on my hat."
Bob then announces, "I can't deduce the number on my hat."
Alice announces, "The number on my hat is 20."
What is the number on Chris's hat?