Here is my accepted code : https://mirror.codeforces.com/contest/1791/submission/192106557
But this code should give TLE if the input is like :
1
200000 200000
a1 , a2 , a3 …… a200000
1 2 200000 (Update index 2 to 200000 and all 200000 queries are like this)