#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
const int maxrand = 10;
const int maxdiv = 7e3;
vector<pair<pair<int, int>, int> > g;
vector<pair<int, int> > v;
int seg[4 * maxn], ans[maxn], a[maxn], n, m;
int mp[maxn];
bool mark[maxn];
void add(int x, int val) {
  for (; x < maxn; x += x & -x) seg[x] += val;
}
int get(int x) {
  int dal = 0;
  for (; x > 0; x -= x & -x) dal += seg[x];
  return dal;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    mp[a[i]] = i;
  }
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j += i)
      v.push_back(make_pair(min(mp[i], mp[j]), max(mp[i], mp[j])));
  for (int i = 1; i <= m; i++) {
    int fi, se;
    scanf("%d%d", &fi, &se);
    g.push_back(make_pair(make_pair(fi, se), i));
  }
  sort(g.begin(), g.end());
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) add(v[i].second, 1);
  int ad = 0;
  int s = 0;
  for (int i = 1; i <= n; i++) {
    while (ad < g.size() and g[ad].first.first == i) {
      ans[g[ad].second] = get(g[ad].first.second);
      ad++;
    }
    while (s < v.size() and v[s].first == i) {
      add(v[s].second, -1);
      s++;
    }
  }
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return printf("\n"), 0;
}
