Comments

I think I have some ideas that can further reduce the $$$\sum n$$$ in Div. 1 D2.

The main observation is that when $$$W$$$ is small, instead of only using copies of $$$1$$$, we can actually insert $$$2$$$ in our second query (If $$$W=1$$$ we'd just get a $$$0$$$).
Assuming we'd be using a lot of $$$2$$$, the function of $$$1$$$ mostly becomes “distinguish odd and even $$$W$$$”, which would imply $$$1$$$ is very sparse (so that two $$$1$$$s wouldn't "neutralize" each other). From there on it's basically trial and error. For example, when $$$B=150$$$, you can generate an article that can distinguish all $$$W\in[1,B]$$$ by putting $$$1$$$ copy of $$$1$$$, $$$127$$$ copies of $$$2$$$, and repeat this for $$$75$$$ times. The rest are pretty much the same.

By choosing $$$N=10800$$$ and $$$B=150$$$, we can yield a $$$\sum n\leq21598$$$ solution. There's most likely room to reduce it even more by picking different $$$N,B$$$ and the article that deals with small $$$W$$$ .

(In fact when I was first solving this I mistakenly used a $$$n=3(R-L)$$$ query in the big $$$W$$$ case, but was somehow still able to pass with this optimization...)