#include <bits/stdc++.h>
using namespace std;
const int MAXN = (const int)(2e5 + 10);
int fen[MAXN], a[MAXN], ans[MAXN];
vector<int> zar[MAXN];
vector<pair<int, int> > q[MAXN];
void add(int p) {
  for (p++; p < MAXN; p += p & -p) {
    fen[p]++;
  }
}
int get(int p) {
  int ret = 0;
  for (; p > 0; p -= p & -p) {
    ret += fen[p];
  }
  return ret;
}
int mp[MAXN];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    mp[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      if (mp[i] > mp[j]) {
        zar[mp[j]].push_back(mp[i]);
      } else {
        zar[mp[i]].push_back(mp[j]);
      }
    }
  }
  for (int i = 0, x, y; i < m; i++) {
    cin >> x >> y;
    q[--x].push_back({y, i});
  }
  if (n == 1) {
    for (int i = 0; i < m; i++) {
      cout << 1 << endl;
    }
    return 0;
  }
  for (int i = n - 1; i > -1; i--) {
    for (auto j : zar[i]) {
      add(j);
    }
    for (auto j : q[i]) {
      ans[j.second] = get(j.first) - get(i);
    }
  }
  for (int i = 0; i < m; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
