Counting in a Range
You are given an array of n integers a_1, a_2, …, a_n, in no particular order. Values may repeat.
Answer q queries. Each query gives two integers l and r and asks: how many indices i satisfy l ≤ a_i ≤ r? Both ends of the range are inclusive. The array never changes between queries.
A query may have l > r; then no value lies in the range and the answer is 0.
Input
The first line contains two integers n and q (1 ≤ n ≤ 2·10^5, 1 ≤ q ≤ 2·10^5).
The second line contains n integers a_1, a_2, …, a_n (−10^9 ≤ a_i ≤ 10^9).
Each of the next q lines contains two integers l and r (−2·10^9 ≤ l, r ≤ 2·10^9).
Output
Print q lines. The j-th line must contain the answer to the j-th query: the number of indices i with l ≤ a_i ≤ r.
Notes
In the first example the array is [5, 1, 9, 3, 7, 3]. The values in [3, 7] are 5, 3, 7, 3, so the first answer is 4. No element lies in [4, 4], all six lie in [-10, 100], and only the 9 lies in [9, 9].
In the second example the last query has l > r, so its answer is 0.