#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 200000 + 10;
int n, arr[nax], fen[nax], pos[nax];
vector<pair<int, pair<int, int> > > queries;
void add(int idx, int val) {
  while (idx <= n) fen[idx] += val, idx += (idx & -idx);
}
int sum(int idx) {
  int res = 0;
  while (idx) res += fen[idx], idx -= (idx & -idx);
  return res;
}
int m;
int ans[nax];
bool cmp(pair<int, pair<int, int> > p1, pair<int, pair<int, int> > p2) {
  if (p1.first == p2.first) return p1.second.second <= p2.second.second;
  return p1.first < p2.first;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &arr[i]), pos[arr[i]] = i;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      int posl = pos[i], posr = pos[j];
      if (posl > posr) swap(posl, posr);
      queries.push_back({posr, {-1, posl}});
    }
  }
  for (int i = 1; i <= m; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    queries.push_back({r, {i, l}});
  }
  sort(queries.begin(), queries.end());
  long long int curans = 0;
  for (auto x : queries) {
    int l = x.second.second, idx = x.second.first;
    if (idx != -1) {
      ans[idx] = curans - sum(l - 1);
      continue;
    }
    curans++;
    add(l, 1);
  }
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}
