
You must return a list of answers, where the i-th element is the count corresponding to the i-th query.
The first line contains a single integer N, the size of the array arr.
The second line contains N space-separated integers, the elements of arr.
The third line contains a single integer Q, the number of queries.
The next Q lines each contain two space-separated integers, low and high, representing a query range.
Print Q lines, where each line contains a single integer representing the answer to the corresponding query.
A naive approach of iterating through the entire array for each query might be too slow and result in a "Time Limit Exceeded" error. Sorting the array first allows for a much more efficient method (like binary search) to find the counts for each range.