#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
struct Ques {
  int l, r, id;
};
int n, m, num;
int a[N], b[N], bit[N];
pair<int, int> c[N * 20];
Ques q[N];
int ans[N];
int cmp1(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
int cmp2(Ques a, Ques b) { return a.r < b.r; }
void C(int i, int d) {
  for (; i <= n; i += i & -i) bit[i] += d;
}
int Q(int i) {
  int res = 0;
  for (; i; i -= i & -i) res += bit[i];
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) b[a[i]] = i;
  for (int i = 1; i <= n; i++)
    if (b[i])
      for (int j = i; j <= n; j += i)
        if (b[j]) {
          c[++num] = make_pair(min(b[i], b[j]), max(b[i], b[j]));
        }
  sort(c + 1, c + 1 + num, cmp1);
  for (int i = 1; i <= m; i++) scanf("%d%d", &q[i].l, &q[i].r), q[i].id = i;
  sort(q + 1, q + 1 + m, cmp2);
  for (int i = 1, j = 1; i <= m; i++) {
    while (j <= num && c[j].second <= q[i].r) {
      C(1, 1);
      C(c[j].first + 1, -1);
      j++;
    }
    ans[q[i].id] = Q(q[i].l);
  }
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}
