Square Root Decomposition

Count how many elements in the range [P, Q] (1 ≤ P ≤ Q ≤ N) have Ai ≤ X
Update : Modify ith number element to X