Comments

E can also be solved with DP: 217832098 so sad during contest i didn't have enough time to remember about case with one point

176213193 which is my way to solve D using sparse table :)