#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 100;
int fen[MAXN];
void upd(int a) {
  for (a++; a < MAXN; a += (a & -a)) fen[a]++;
}
int get(int a) {
  int res = 0;
  for (a++; a > 0; a -= (a & -a)) res += fen[a];
  return res;
}
vector<int> ver[MAXN];
vector<pair<int, int>> que[MAXN];
int p[MAXN];
int res[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  int qn;
  cin >> qn;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    p[x] = i;
  }
  for (int i = 1; i <= n; i++)
    for (int j = i + i; j <= n; j += i)
      if (p[i] < p[j])
        ver[p[j]].push_back(p[i]);
      else
        ver[p[i]].push_back(p[j]);
  for (int i = 0; i < qn; i++) {
    int x, y;
    cin >> x >> y;
    que[y].push_back({x, i});
  }
  for (int i = 1; i <= n; i++) {
    upd(i);
    for (auto u : ver[i]) upd(u);
    for (auto u : que[i]) res[u.second] = get(i) - get(u.first - 1);
  }
  for (int i = 0; i < qn; i++) cout << res[i] << '\n';
}
