#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, m, p[N], inv[N], tree[N], ans[N];
vector<int> prevDivs[N];
vector<pair<int, int> > qs[N];
void update(int i, int v) {
  while (i < N) tree[i] += v, i += i & -i;
}
int query(int i) {
  int ret = 0;
  while (i > 0) ret += tree[i], i -= i & -i;
  return ret;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int(i) = (1); (i) <= (int)(n); (i)++) scanf("%d", &p[i]), inv[p[i]] = i;
  for (int(i) = (1); (i) <= (int)(n); (i)++) {
    for (int j = i; j <= n; j += i) {
      if (inv[j] <= inv[i])
        prevDivs[inv[i]].push_back(inv[j]);
      else
        prevDivs[inv[j]].push_back(inv[i]);
    }
  }
  for (int(i) = (1); (i) <= (int)(m); (i)++) {
    int l, r;
    scanf("%d%d", &l, &r);
    qs[r].push_back({l, i});
  }
  for (int(i) = (1); (i) <= (int)(n); (i)++) {
    for (int x : prevDivs[i]) update(x, 1);
    for (pair<int, int> q : qs[i])
      ans[q.second] = query(i) - query(q.first - 1);
  }
  for (int(i) = (1); (i) <= (int)(m); (i)++) printf("%d\n", ans[i]);
  return 0;
}
