#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
vector<int> factor[maxn];
vector<pair<int, int> > query[maxn];
int n, m, ret;
int tr[maxn], a[maxn], ans[maxn], pos[maxn];
void Read() {
  int i, x, y;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]), pos[a[i]] = i;
  for (i = 1; i <= m; i++)
    scanf("%d%d", &x, &y), query[y].push_back(make_pair(x, i));
}
void Update(int x) {
  for (; x <= n; x += x & -x) tr[x]++;
}
int Query(int x) {
  for (ret = 0; x; x -= x & -x) ret += tr[x];
  return ret;
}
void Solve() {
  int i, j, t;
  for (i = 1; i <= n; i++)
    for (j = i; j <= n; j += i) factor[j].push_back(i);
  for (i = 1; i <= n; i++) {
    for (j = 0; j < factor[a[i]].size(); j++) {
      t = pos[factor[a[i]][j]];
      if (t <= i) Update(t);
    }
    for (j = 2; a[i] * j <= n; j++) {
      t = pos[a[i] * j];
      if (t <= i) Update(t);
    }
    for (j = 0; j < query[i].size(); j++)
      ans[query[i][j].second] = Query(i) - Query(query[i][j].first - 1);
  }
  for (i = 1; i <= m; i++) printf("%d\n", ans[i]);
}
int main() {
  Read();
  Solve();
}
