#include <bits/stdc++.h>
using namespace std;
const int maxn = 262144;
int s[maxn * 2];
int n, q;
int pos[maxn];
int l[maxn], r[maxn];
int ans[maxn];
vector<int> A[maxn], B[maxn];
void add(int seg, int ls, int rs, int ind) {
  if (rs <= ind or ind < ls) return;
  if (ls == rs - 1) {
    s[seg]++;
    return;
  }
  int mid = (ls + rs) >> 1;
  add(seg * 2 + 1, ls, mid, ind);
  add(seg * 2 + 2, mid, rs, ind);
  s[seg]++;
}
int sum(int seg, int ls, int rs, int ind) {
  if (ind < ls) return 0;
  if (rs <= ind + 1) return s[seg];
  int mid = (ls + rs) >> 1;
  return sum(seg * 2 + 1, ls, mid, ind) + sum(seg * 2 + 2, mid, rs, ind);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  scanf("%d%d", &n, &q);
  for (int x, i = 0; i < n; i++) {
    scanf("%d", &x);
    pos[x] = i;
  }
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j += i)
      A[min(pos[i], pos[j])].push_back(max(pos[i], pos[j]));
  for (int i = 0; i < q; i++) {
    scanf("%d%d", l + i, r + i);
    l[i]--, r[i]--;
    B[l[i]].push_back(i);
  }
  for (int i = n; i--;) {
    for (int j = 0; j < A[i].size(); j++) add(0, 0, n, A[i][j]);
    for (int j = 0; j < B[i].size(); j++)
      ans[B[i][j]] += sum(0, 0, n, r[B[i][j]]);
  }
  for (int i = 0; i < q; i++) printf("%d\n", ans[i]);
  return 0;
}
