Prerequisites
The main idea comes from the sliding window technique. Suppose you have q queries where every query has a fixed length (r - l) = k. You can answer each query by combining information from two blocks of size k-1 use the suffix v left block and the prefix right block. Then, you can compute the ans using those two values.



