#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[200005], pos[200005];
vector<int> gr[200005];
vector<pair<int, int> > query[200005];
int tree[4 * 200005], ans[200005];
int sum(int node, int tl, int tr, int l, int r) {
  if (l > r) return 0;
  if (l == tl && r == tr) return tree[node];
  int mid = (tl + tr) / 2;
  return (sum(node * 2, tl, mid, l, min(r, mid)) +
          sum(node * 2 + 1, mid + 1, tr, max(l, mid + 1), r));
}
void update(int node, int l, int r, int pos, int val) {
  if (l == r)
    tree[node] += val;
  else {
    int mid = (l + r) / 2;
    if (pos <= mid)
      update(node * 2, l, mid, pos, val);
    else
      update(node * 2 + 1, mid + 1, r, pos, val);
    tree[node] = (tree[node * 2] + tree[node * 2 + 1]);
  }
}
int main() {
  int i, j;
  scanf("%d", &n);
  scanf("%d", &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    pos[a[i]] = i;
  }
  for (i = 1; i <= n; i++) {
    for (j = i; j <= n; j += i) {
      gr[min(pos[i], pos[j])].push_back(max(pos[i], pos[j]));
    }
  }
  for (i = 1; i <= m; i++) {
    int l, r;
    scanf("%d", &l);
    scanf("%d", &r);
    query[l].push_back({r, i});
  }
  for (i = n; i >= 1; i--) {
    for (auto to : gr[i]) update(1, 1, n, to, 1);
    for (auto to : query[i]) ans[to.second] = sum(1, 1, n, i, to.first);
  }
  for (i = 1; i <= m; i++) printf("%d\n", ans[i]);
}
