#include <bits/stdc++.h>
using namespace std;
long long n, m, u, v, i, f[1000100], a[1000100], j, k;
struct g {
  long long l, r, id;
} d[1000100];
long long c[1000100], ans[1000100];
long long lowbit(long long x) { return (x & (-x)); }
void cc(long long x, long long w) {
  while (x <= n) {
    c[x] += w;
    x = x + lowbit(x);
  }
}
long long sum(long long x) {
  long long ans = 0;
  while (x) {
    ans = ans + c[x];
    x = x - lowbit(x);
  }
  return ans;
}
bool cmp1(g a, g b) { return a.l < b.l; }
bool cmp2(g a, g b) { return a.r > b.r; }
int main() {
  scanf("%I64d%I64d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    f[a[i]] = i;
  }
  for (i = 1; i <= n; i++)
    for (j = i; j <= n; j = j + i) cc(f[j], 1);
  for (i = 1; i <= m; i++) {
    scanf("%I64d%I64d", &d[i].l, &d[i].r);
    d[i].id = i;
  }
  sort(d + 1, d + 1 + m, cmp1);
  k = 1;
  for (i = 1; i <= n; i++) {
    while ((d[k].l == i) && (k <= m)) {
      ans[d[k].id] = sum(d[k].r) - sum(i - 1);
      k++;
    }
    for (j = a[i]; j <= n; j = j + a[i]) cc(f[j], -1);
  }
  sort(d + 1, d + 1 + m, cmp2);
  k = 1;
  for (i = n; i >= 1; i--) {
    while ((d[k].r == i) && (k <= m)) {
      ans[d[k].id] = ans[d[k].id] - (sum(n - d[k].l + 1) - sum(n - d[k].r));
      k++;
    }
    for (j = a[i]; j <= n; j = j + a[i]) cc(n - f[j] + 1, 1);
  }
  for (i = 1; i <= m; i++) printf("%I64d\n", ans[i]);
}
