according to this cf blog, you just have to sort the queries using the comparator below.

```
S = the max integer number which is less than sqrt(N);
bool cmp(Query A, Query B)
{
if (A.l / S ！= B.l / S) return A.l / S < B.l / S;
return A.r > B.r
}
```

then processing queries takes a total of \mathcal O(Q\sqrt N) for distinct value queries.

what’s so significant about the sorting function and why does sorting it result in a \sqrt N complexity?