#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int n, m;
int a[N], pos[N], l[N], r[N], c[N], ans[N];
vector<int> v[N], q[N];
void ins(int x) {
  for (; x <= n; x += -x & x) c[x]++;
}
int ask(int x) {
  int res = 0;
  for (; x; x -= -x & x) res += c[x];
  return res;
}
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", &l[i], &r[i]);
    q[l[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j * a[i] <= n; j++) {
      int p = pos[j * a[i]];
      if (p < i)
        v[p].push_back(i);
      else
        v[i].push_back(p);
    }
  }
  for (int i = n; i; i--) {
    for (auto x : v[i]) ins(x);
    for (auto x : q[i]) ans[x] = ask(r[x]);
  }
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}
