#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> t;
void inc(int i) {
  for (; i <= n; i = (i | (i + 1))) ++t[i];
}
int sum(int i) {
  int ot = 0;
  for (; i >= 0; i = ((i) & (i + 1)) - 1) ot += t[i];
  return ot;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int haha = 0;
  cin >> n >> m;
  t.resize(n, 0);
  vector<int> hoho(n, 0);
  vector<vector<int> > mem(n);
  int a[n], pos[n + 1];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  pair<pair<int, int>, int> q[m];
  for (int i = 0; i < m; ++i) {
    cin >> q[i].first.second >> q[i].first.first;
    q[i].second = i;
    --q[i].first.first;
    --q[i].first.second;
  }
  vector<int> ot(m);
  sort(q, q + m);
  int now = 0;
  for (int i = 0; i < n && now < m; ++i) {
    for (int d = 1; d <= sqrt(a[i]); ++d) {
      if (a[i] % d) continue;
      if (pos[a[i]] >= pos[d]) {
        ++hoho[i];
        mem[i].push_back(pos[d]);
      } else {
        ++hoho[pos[d]];
        mem[pos[d]].push_back(i);
      }
      if (d * d == a[i]) continue;
      if (pos[a[i]] > pos[a[i] / d]) {
        ++hoho[i];
        mem[i].push_back(pos[a[i] / d]);
      } else {
        ++hoho[pos[a[i] / d]];
        mem[pos[a[i] / d]].push_back(i);
      }
    }
    haha += hoho[i];
    for (auto kek : mem[i]) inc(kek);
    while (i == q[now].first.first && now < m) {
      int z38 = haha;
      if (q[now].first.second) z38 -= sum(q[now].first.second - 1);
      ot[q[now].second] = z38;
      ++now;
    }
  }
  for (int i = 0; i < m; ++i) cout << ot[i] << '\n';
  return 0;
}
