#include <bits/stdc++.h>
using namespace std;
const int MaxN = 200005;
struct segment {
  int left, right;
  segment() {}
  segment(int _left, int _right) {
    left = _left;
    right = _right;
    if (left > right) swap(left, right);
  }
  bool operator<(const segment &a) const { return right < a.right; }
} s[MaxN * 30];
struct query {
  int l, r, idx;
  query() {}
  query(int _l, int _r, int _idx) {
    l = _l;
    r = _r;
    idx = _idx;
  }
  bool operator<(const query &a) const { return r < a.r; }
} q[MaxN];
int p[MaxN];
int idx[MaxN];
int c[MaxN];
int n;
void add(int idx, int val) {
  while (idx <= n) {
    c[idx] += val;
    idx += idx & -idx;
  }
}
int read(int idx) {
  int ret = 0;
  while (idx) {
    ret += c[idx];
    idx -= idx & -idx;
  }
  return ret;
}
int sol[MaxN];
int main() {
  int m;
  scanf("%d%d", &n, &m);
  memset(idx, 0, sizeof(idx));
  for (int i = 1; i <= n; i++) scanf("%d", p + i), idx[p[i]] = i;
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j += i) {
      s[++cnt] = segment(idx[i], idx[j]);
    }
  for (int i = 1; i <= m; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    q[i] = query(l, r, i);
  }
  sort(q + 1, q + m + 1);
  sort(s + 1, s + cnt + 1);
  memset(c, 0, sizeof(c));
  int j = 1;
  for (int i = 1; i <= m; i++) {
    while (j <= cnt && s[j].right <= q[i].r) {
      add(s[j].left, 1);
      j++;
    }
    sol[q[i].idx] = read(q[i].r) - read(q[i].l - 1);
  }
  for (int i = 1; i <= m; i++) printf("%d\n", sol[i]);
  return 0;
}
