#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
int n, p[N], m, idx[N];
long long sum[4 * N], ans[N];
pair<pair<int, int>, int> q[N];
vector<int> id[N];
void add(int i, int lo, int hi, int ql) {
  if (lo == hi) {
    sum[i]++;
    return;
  }
  int mid = lo + hi >> 1;
  if (ql <= mid)
    add(2 * i, lo, mid, ql);
  else
    add(2 * i + 1, mid + 1, hi, ql);
  sum[i] = sum[2 * i] + sum[2 * i + 1];
}
long long ask(int i, int lo, int hi, int ql, int qr) {
  if (qr < lo || hi < ql) return 0;
  if (ql <= lo && hi <= qr) return sum[i];
  int mid = lo + hi >> 1;
  return ask(2 * i, lo, mid, ql, qr) + ask(2 * i + 1, mid + 1, hi, ql, qr);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", p + i);
    idx[p[i]] = i;
  }
  for (int i = 1; i <= m; i++)
    scanf("%d%d", &q[q[i].second = i].first.first, &q[i].first.second);
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j += i) {
      if (idx[j] > idx[i])
        id[i].push_back(idx[j]);
      else
        id[j].push_back(idx[i]);
    }
  sort(q + 1, q + m + 1);
  int mm = m;
  memset(sum, 0, sizeof sum);
  int l, r;
  int st = n;
  int x;
  while (m--) {
    l = q[m + 1].first.first, r = q[m + 1].first.second;
    while (st >= l) {
      x = p[st];
      while ((int)id[x].size() && id[x].back() >= l) {
        add(1, 1, n, id[x].back());
        id[x].pop_back();
      }
      st--;
    }
    ans[q[m + 1].second] = ask(1, 1, n, l, r);
  }
  for (int i = 1; i <= mm; i++) printf("%I64d\n", ans[i]);
  return 0;
}
