#include <bits/stdc++.h>
using namespace std;
const int MAXN = int(2e5) + 1;
long long st[MAXN * 4], ans[MAXN];
int A[MAXN], N, M, pos[MAXN];
struct datapos {
  vector<pair<int, int>> q;
  vector<int> lefties;
} d[MAXN];
void st_upd(int si, int ss, int se, int pos) {
  assert(pos <= se);
  assert(pos >= ss);
  if (ss == se) {
    assert(ss == pos);
    st[si]++;
  } else {
    int mid = (ss + se) / 2;
    if (pos <= mid)
      st_upd(si * 2, ss, mid, pos);
    else
      st_upd(si * 2 + 1, mid + 1, se, pos);
    st[si] = st[si * 2] + st[si * 2 + 1];
  }
}
long long st_que(int si, int ss, int se, int left, int right) {
  assert(ss <= se);
  assert(left <= right);
  if (left > se || right < ss) return 0;
  if (left <= ss && se <= right) return st[si];
  int mid = (ss + se) / 2;
  return st_que(si * 2, ss, mid, left, right) +
         st_que(si * 2 + 1, mid + 1, se, left, right);
}
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; i++) {
    scanf("%d", A + i);
    pos[A[i]] = i;
  }
  for (int queryi = 0, left, right; queryi < M; queryi++) {
    scanf("%d%d", &left, &right);
    d[right].q.push_back({left, queryi});
  }
  for (int num = 1; num <= N; num++) {
    for (int multi = num; multi <= N; multi += num) {
      int left = min(pos[num], pos[multi]);
      int right = max(pos[num], pos[multi]);
      d[right].lefties.push_back(left);
    }
  }
  for (int posi = 1; posi <= N; posi++) {
    for (auto left : d[posi].lefties) st_upd(1, 1, N, left);
    for (auto qu : d[posi].q) ans[qu.second] = st_que(1, 1, N, qu.first, posi);
  }
  for (int i = 0; i < M; i++) printf("%lld\n", ans[i]);
  return 0;
}
