#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 rev(N+1), A(N+1); vector> v(N+1); A[0] = -2e9; for (int i=1; i<=N; i++){ cin >> A[i]; v[i] = {-A[i], i}; } sort(v.begin(), v.end()); for (int i=1; i<=N; i++) rev[v[i].second] = i; for (int i=0; i> x >> y; if (A[x] <= A[y]) cout << 0 << endl; else{ cout << rev[y]-rev[x]-1 << endl; } } return 0; }