#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n, m;
int seg[maxn << 2];
vector<int> divisiors[maxn], ansqrs[maxn];
vector<pair<int, int>> qrs;
int ans[maxn];
int a[maxn], pos[maxn];
void change(int pos, int id = 1, int s = 0, int e = n) {
  if (e - s == 1) {
    seg[id]++;
    return;
  }
  int mid = (s + e) >> 1;
  if (pos < mid)
    change(pos, id << 1, s, mid);
  else
    change(pos, id << 1 | 1, mid, e);
  seg[id] = seg[id << 1] + seg[id << 1 | 1];
}
int get(int l, int r, int id = 1, int s = 0, int e = n) {
  if (e <= l || s >= r) return 0;
  if (e <= r && s >= l) return seg[id];
  int mid = (s + e) >> 1;
  return get(l, r, id << 1, s, mid) + get(l, r, id << 1 | 1, mid, e);
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    pos[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) divisiors[j].push_back(i);
  }
  for (int i = 0; i < m; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    l--;
    qrs.push_back(make_pair(l, r));
    ansqrs[r - 1].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    for (int j = a[i]; j <= n; j += a[i]) {
      if (pos[j] <= i) change(pos[j]);
    }
    for (int div : divisiors[a[i]]) {
      if (pos[div] < i) change(pos[div]);
    }
    for (int id : ansqrs[i]) ans[id] = get(qrs[id].first, qrs[id].second);
  }
  for (int i = 0; i < m; i++) printf("%d\n", ans[i]);
}
