#include <bits/stdc++.h>
using namespace std;
char ch, B[1 << 20], *S = B, *T = B;
int aa, bb;
int rd() {
  while (ch = (S == T && (T = (S = B) + fread(B, 1, 1 << 20, stdin), S == T)
                   ? 0
                   : *S++),
         !(ch >= '0' && ch <= '9') && ch != '-')
    ;
  ch == '-' ? aa = bb = 0 : (aa = ch - '0', bb = 1);
  while (ch = (S == T && (T = (S = B) + fread(B, 1, 1 << 20, stdin), S == T)
                   ? 0
                   : *S++),
         (ch >= '0' && ch <= '9'))
    aa = aa * 10 + ch - '0';
  return bb ? aa : -aa;
}
const int MAXN = 2e5 + 10;
int n, m, p[MAXN], tr[MAXN], ans[MAXN], pos[MAXN];
struct Node {
  int l, r, id;
} a[MAXN], b[MAXN];
bool cmp1(Node a, Node b) { return a.l == b.l ? a.r < b.r : a.l < b.l; }
bool cmp2(Node a, Node b) { return a.r == b.r ? a.l < b.l : a.r < b.r; }
inline void add(int x, int c) {
  while (x <= n) {
    tr[x] += c;
    x += (x & (-x));
  }
}
int sum(int x) {
  int ret = 0;
  while (x) {
    ret += tr[x];
    x -= (x & (-x));
  }
  return ret;
}
inline void work() {
  n = rd();
  m = rd();
  for (register int i = 1; i <= n; ++i) {
    p[i] = rd();
    pos[p[i]] = i;
  }
  for (register int i = 1; i <= m; ++i) {
    int l = rd(), r = rd();
    a[i].l = l;
    a[i].r = r;
    a[i].id = i;
    b[i] = a[i];
  }
  sort(a + 1, a + m + 1, cmp1);
  sort(b + 1, b + m + 1, cmp2);
  int j = 1, k = 1;
  for (register int i = 1; i <= n; ++i) {
    while (a[j].l == i && j <= m) {
      ans[a[j].id] -= sum(a[j].r) - sum(a[j].l - 1);
      ++j;
    }
    for (register int l = 1; l * p[i] <= n; ++l) add(pos[l * p[i]], 1);
    while (b[k].r == i && k <= m) {
      ans[b[k].id] += sum(b[k].r) - sum(b[k].l - 1);
      ++k;
    }
  }
  for (register int i = 1; i <= m; ++i) printf("%d\n", ans[i]);
}
int main() {
  work();
  return 0;
}
