#include using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int N, Q, x, y; cin >> N >> Q; vector A(N), B; for (int i=0; i> A[i]; B = A; sort(B.begin(), B.end()); for (int i=0; i> x >> y; x--; y--; if (A[y] >= A[x]) cout << 0 << endl; else cout << lower_bound(B.begin(), B.end(), A[x]) - upper_bound(B.begin(), B.end(), A[y]) << endl; } return 0; }