I had an idea for a magic item for D&D not too long ago. It works something like this:
Pick some number of dice to roll, and if none of them are a 1, then you gain hit points equal to the sum of the dice. But if even one die is a 1, then you instead lose hit points equal to the sum of the dice.
So of course, being a fellow with some background in mathematics and a penchant for giving myself problems to solve, I decided to figure out how many dice you should roll in order to maximize your expected value.