#include <bits/stdc++.h>
using namespace std;
int n, k, cmo, mal;
long long T[200009 * 4], res[200009];
vector<int> par[200009];
int a[200009], yer[200009], pars[200009];
vector<pair<int, int> > v[200009];
void build(int l, int r, int node) {
  if (l == r) {
    T[node] = pars[l];
    return;
  }
  build(l, (l + r) / 2, node * 2 + 1);
  build((l + r) / 2 + 1, r, node * 2);
  T[node] = T[node * 2] + T[node * 2 + 1];
}
long long search(int x, int y, int l, int r, int node) {
  if (x <= l && r <= y) return T[node];
  if (l > y || r < x) return 0ll;
  return search(x, y, l, (l + r) / 2, node * 2 + 1) +
         search(x, y, (l + r) / 2 + 1, r, node * 2);
}
void upd(int x, int l, int r, int node) {
  if (l == r) {
    T[node]--;
    return;
  }
  if (x <= (l + r) / 2)
    upd(x, l, (l + r) / 2, node * 2 + 1);
  else
    upd(x, (l + r) / 2 + 1, r, node * 2);
  T[node] = T[node * 2] + T[node * 2 + 1];
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), yer[a[i]] = i;
  for (int i = 0; i < k; i++) {
    scanf("%d%d", &cmo, &mal);
    v[cmo].push_back({mal, i});
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      int yeri = yer[i], yerj = yer[j], yerh = yer[i];
      if (yeri > yerj) yeri = yerj, yerj = yerh;
      pars[yerj]++;
      par[a[yeri]].push_back(a[yerj]);
    }
  }
  build(1, n, 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < v[i].size(); j++)
      res[v[i][j].second] = search(i, v[i][j].first, 1, n, 1);
    for (int j = 0; j < par[a[i]].size(); j++) upd(yer[par[a[i]][j]], 1, n, 1);
  }
  for (int i = 0; i < k; i++) printf("%I64d\n", res[i]);
  return 0;
}
