#include <bits/stdc++.h>
using namespace std;
void fastscan(int &number) {
  bool negative = false;
  register int c;
  number = 0;
  c = getchar();
  if (c == '-') {
    negative = true;
    c = getchar();
  }
  for (; (c > 47 && c < 58); c = getchar()) number = number * 10 + c - 48;
  if (negative) number *= -1;
}
const int N = 2e5 + 5;
int arr[N], seg[4 * N], ind[N], p[N], ans[N];
vector<int> start[N];
vector<pair<int, int>> q[N];
void build(int l, int u, int i) {
  if (l == u) {
    seg[i] = arr[l];
    return;
  }
  build(l, ((l + u) / 2), (i * 2 + 1));
  build(((l + u) / 2) + 1, u, (i * 2 + 2));
  seg[i] = seg[(i * 2 + 1)] + seg[(i * 2 + 2)];
}
int query(int l, int u, int i, int ll, int uu) {
  if (l >= ll && u <= uu) return seg[i];
  if (l > uu || u < ll) return 0;
  return query(l, ((l + u) / 2), (i * 2 + 1), ll, uu) +
         query(((l + u) / 2) + 1, u, (i * 2 + 2), ll, uu);
}
void update(int l, int u, int i, int uu, int upval) {
  if (l >= uu && u <= uu) {
    seg[i] += upval;
    return;
  }
  if (l > uu || u < uu) return;
  update(l, ((l + u) / 2), (i * 2 + 1), uu, upval);
  update(((l + u) / 2) + 1, u, (i * 2 + 2), uu, upval);
  seg[i] = seg[(i * 2 + 1)] + seg[(i * 2 + 2)];
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    ind[p[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      int a = ind[i] + 1, b = ind[j] + 1;
      if (a > b) swap(a, b);
      start[a].push_back(b);
      arr[b]++;
    }
  }
  build(1, n, 0);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    q[u].push_back(make_pair(v, i));
  }
  int toremove = 1;
  for (int i = 1; i <= n; i++) {
    while (toremove < i) {
      for (int j : start[toremove]) update(1, n, 0, j, -1);
      toremove++;
    }
    for (pair<int, int> lol : q[i]) {
      ans[lol.second] = query(1, n, 0, i, lol.first);
    }
  }
  for (int i = 0; i < m; i++) cout << ans[i] << "\n";
  return 0;
}
