#include <bits/stdc++.h>
using namespace std;
int n, q;

int main()
{
    cin >> n >> q;
    vector<int> a(n), b, c(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == pow(2, log2(a[i])))
            b.push_back(i);
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < b.size();j++) {
            if (a[i] > a[b[j]] && a[i] < 2 * a[b[j]])
                c[i]++;
        }
    }
    for (int i = 1; i < n; i++) {
        c[i] += c[i - 1];
    }
    while(q--){
        int l, r;
        cin >> l >> r;
        l--, r--;
        cout << c[r] - c[l] + 1 << endl;
    }
    return 0;
}