#include <bits/stdc++.h>
using namespace std;
int n, q;
vector<int> oni[200009], son[200009];
vector<pair<int, int> > Q[200009];
int sanavach[200009];
int arr[200009];
int res[200009];
int sum[200009];
int ans = 0;
void upd(int x) {
  for (int i = x; i <= n; i += (i & -i)) sum[i]++;
}
int ask(int x) {
  int nw = 0;
  for (int i = x; i > 0; i -= (i & -i)) nw += sum[i];
  return nw;
}
int calc(int l, int r) { return abs(ask(r - 1) - ask(l)); }
int pos[200009];
int main() {
  cin >> n;
  cin >> q;
  int a;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    pos[a] = i;
  }
  int l, r;
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &l, &r);
    Q[r].push_back({l, i});
  }
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j += i)
      son[max(pos[i], pos[j])].push_back(min(pos[i], pos[j]));
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < (int)son[i].size(); j++) upd(son[i][j]);
    for (int j = 0; j < (int)Q[i].size(); j++)
      res[Q[i][j].second] = calc(i, Q[i][j].first);
  }
  for (int i = 1; i <= q; i++) printf("%d\n", res[i]);
  return 0;
}
