#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, m, k;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
long long ln, lk, lm;
int p[200105], B, id[200105];
struct qy {
  int id, l, r;
  bool operator<(const qy &b) const {
    if (l == b.l) return r < b.r;
    return l < b.l;
  }
} q[200105];
vector<int> vp[200105];
void pre() {
  for (int i = 1; i <= n; i++) {
    for (int j = i + i; j <= n; j += i) {
      vp[min(id[i], id[j])].push_back(max(id[i], id[j]));
    }
  }
}
long long b[200105], ans[200105];
void update(int x, int val) {
  for (int i = x; i <= n; i += i & -i) {
    b[i] += val;
  }
}
long long query(int x) {
  int ret = 0;
  for (; x > 0; ret += b[x], x -= x & -x)
    ;
  return ret;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%d", p + i);
    id[p[i]] = i;
  }
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    scanf("%d%d", &q[i].l, &q[i].r);
    q[i].id = i;
  }
  sort(q + 1, q + 1 + m);
  pre();
  int l = 0, r = 0;
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    while (r < q[i].r) {
      r++;
      for (int c : vp[r]) update(c, 1);
    }
    while (l < q[i].l) {
      for (int c : vp[l]) update(c, -1);
      l++;
    }
    ans[q[i].id] = query(q[i].r) + q[i].r - q[i].l + 1;
  }
  for (int(i) = 1; (i) <= (int)(m); (i)++) printf("%lld\n", ans[i]);
  return 0;
}
