Sponsored
Use these hints if you're stuck. Try solving on your own first.
It's optimal to always remove one stone from the biggest 2 piles
Note that the limits are small enough for simulation
Solve with full IDE support and test cases