#include <bits/stdc++.h>
using namespace std;
const int Maxn = 200005;
int n, m;
int a[Maxn], Pos[Maxn], bit[Maxn];
int ans[Maxn];
int lowbit(int x) { return x & (-x); }
int sum(int x) {
  int res = 0;
  while (x > 0) {
    res += bit[x];
    x -= lowbit(x);
  }
  return res;
}
void update(int x, int val) {
  while (x <= n) {
    bit[x] += val;
    x += lowbit(x);
  }
}
struct node {
  int pos, l, r;
} q1[Maxn], q2[Maxn];
bool cmp(node a, node b) { return a.l < b.l; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    Pos[a[i]] = i;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &q1[i].l, &q1[i].r);
    q2[i].l = q1[i].r;
    q2[i].r = q1[i].l;
    q1[i].pos = q2[i].pos = i;
  }
  sort(q1 + 1, q1 + m + 1, cmp);
  sort(q2 + 1, q2 + m + 1, cmp);
  for (int i = 1, j = 1, k = 1; i <= n; ++i) {
    while (j <= m && q1[j].l == i) {
      ans[q1[j].pos] -= sum(q1[j].r) - sum(q1[j].l - 1);
      ++j;
    }
    for (int p = a[i]; p <= n; p += a[i]) update(Pos[p], 1);
    while (k <= m && q2[k].l == i) {
      ans[q2[k].pos] += sum(q2[k].l) - sum(q2[k].r - 1);
      ++k;
    }
  }
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}
