#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10, radical = 300;
int pos[maxn];
int a[maxn];
vector<int> v[maxn];
vector<pair<int, int> > Q[maxn];
int ans[maxn];
int fen[maxn];
inline void add(int id) {
  id++;
  while (id < maxn) {
    fen[id]++;
    id += id & -id;
  }
}
inline int get(int id) {
  id++;
  int ret = 0;
  while (id) {
    ret += fen[id];
    id -= id & -id;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j += i)
      if (pos[i] < pos[j])
        v[pos[j]].push_back(pos[i]);
      else
        v[pos[i]].push_back(pos[j]);
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    Q[r].push_back(pair<int, int>(l, i));
  }
  int tot = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < v[i].size(); j++) add(v[i][j]);
    tot += v[i].size();
    for (int j = 0; j < Q[i].size(); j++)
      ans[Q[i][j].second] = tot - get(Q[i][j].first - 1);
  }
  for (int i = 0; i < q; i++) cout << ans[i] << " ";
  return 0;
}
