HELP in understanding better DRCHEF

Refer to this solution and pls tell me where was i going wrong?

Test case
3 10
8 23 30
Answer should be 4 and not 5.

see! its 4 only

Maybe this will help you find where you are getting wrong.

I ran your code for this test case and i got 5.