#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, q;
cin >> n >> q;
vector<long long> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
sort(a.begin(), a.end());
while (q--) {
long long l, r;
cin >> l >> r;
auto left = lower_bound(a.begin(), a.end(), l);
auto right = upper_bound(a.begin(), a.end(), r);
cout << (right - left) << '\n';
}
return 0;
}

京公网安备 11010502036488号