Question related to slope trick

I was looking through the slope trick module (Slope Trick), and found this follow up question to Problem - D - Codeforces,

Stock Trading (USACO Camp): What if your amount of shares can go negative, but you can never have more than L shares or less than −L?

I was able to solve the original question but have no idea how to solve the follow up. Any ideas/hints?

It’s similar to the solution described in the module (maintain the differences between consecutive DP values in a sorted set).