Store the queries from [ L + 1 , R - 1 ] .
queries [ j ] . l = left + 1 NEW_LINE queries [ j ] . r = right - 1 NEW_LINE queries [ j ] . x = minn NEW_LINE queries [ j ] . index = j NEW_LINE j += 1 NEW_LINE Fenwick = [ 0 for _ in range ( n + 1 ) ] NEW_LINE q = j - 1 NEW_LINE