You have a collection of stones, each with a positive weight. Each turn, you take the two heaviest stones and smash them. If they're equal, both are destroyed.
Otherwise, the lighter one is destroyed and the heavier one loses weight equal to the lighter. Return the weight of the last stone, or if no stones remain.
You're solving a warm-up heap problem. You repeatedly need the two largest elements.