Https://ide.codingblocks.com/#/s/13667

https://ide.codingblocks.com/#/s/13667
calculate the sum only 1 test case passed please see

Hello Keshav ! Actually if you think about this question there is no need of writing so much lines of code , ur code have time complexity of order q*n, but this question can be solved in just O(q) time.
Hint -->> if you add every element by its previous element which is at a distance x then its value will change but every time it’s total sum will be integral multiple of the initial sum and have proportionality to it. So think about it in terms of total array sum at every query and find relation between them.
If in case you still have doubt on it , do ask me .