#include <bits/stdc++.h>
using namespace std;
const long N = 210000;
vector<long> R[N], L[N];
long i, j, x, n, m, b[N] = {}, p[N] = {}, l[N] = {}, r[N] = {}, ans[N] = {};
struct Tree {
  long l, r, s;
} a[5 * N] = {};
void build(long k) {
  if (a[k].l == a[k].r) return;
  long lc = 2 * k, rc = 2 * k + 1;
  a[k].s = 0;
  a[lc].l = a[k].l;
  a[lc].r = (a[k].l + a[k].r) / 2;
  a[rc].l = a[lc].r + 1;
  a[rc].r = a[k].r;
  build(lc);
  build(rc);
}
void change(long k, long x) {
  if (a[k].l != a[k].r)
    if (a[2 * k].r >= x)
      change(2 * k, x);
    else
      change(2 * k + 1, x);
  a[k].s++;
}
long search(long k, long l, long r) {
  if ((l > a[k].l) || (a[k].r > r)) {
    long lc = 2 * k, rc = 2 * k + 1, t = 0;
    if (a[lc].r >= l) t += search(lc, l, r);
    if (a[rc].l <= r) t += search(rc, l, r);
    return t;
  } else
    return a[k].s;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> b[i];
    p[b[i]] = i;
  }
  for (i = 0; i < m; i++) {
    cin >> l[i] >> r[i];
    L[l[i]].push_back(i);
    R[r[i]].push_back(i);
  }
  a[1].l = 1;
  a[1].r = n;
  build(1);
  for (i = 1; i <= n; i++) {
    for (j = 0; j < L[i].size(); j++)
      ans[L[i][j]] -= search(1, l[L[i][j]], r[L[i][j]]);
    for (x = b[i]; x <= n; x += b[i]) change(1, p[x]);
    for (j = 0; j < R[i].size(); j++)
      ans[R[i][j]] += search(1, l[R[i][j]], r[R[i][j]]);
  }
  for (i = 0; i < m; i++) cout << ans[i] << endl;
  return 0;
}
