if queries [ i ] . index < q :
ans [ queries [ i ] . index ] = query ( Fenwick , queries [ i ] . r + 1 , n ) - query ( Fenwick , queries [ i ] . l , n ) NEW_LINE for i in range ( q + 1 ) : NEW_LINE mx = max ( mx , ans [ i ] ) NEW_LINE