Calculate sum code

https://hack.codingblocks.com/contests/c/474/1410
// calculate sum code

https://ide.codingblocks.com/#/s/13665

Getting wrong ans. for one test case…!

Hey Nitesh ! 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.