#include <bits/stdc++.h>
using namespace std;
int p[400000 + 5], ink[400000 + 5];
vector<pair<int, int> > E;
struct query {
  int l, r, idx;
  query(int _l, int _r, int _idx) {
    l = _l;
    r = _r;
    idx = _idx;
  }
  bool operator<(const query &T) const { return l < T.l; }
};
int ans[400000 + 5];
vector<query> Q;
struct TA {
  int a[400000 + 5];
  int n;
  void Init(int n) {
    this->n = n;
    memset(a, 0, sizeof(int) * n);
  }
  void add(int p, int x) {
    for (p; p <= n; p += p & -p) a[p] += x;
  }
  int get(int pos) {
    pos = min(pos, n);
    int r = 0;
    for (; pos; pos -= pos & -pos) r += a[pos];
    return r;
  }
} ta;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
    ink[p[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      E.push_back(make_pair(min(ink[i], ink[j]), max(ink[i], ink[j])));
    }
  }
  sort(E.begin(), E.end());
  for (int i = 0; i < m; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    Q.push_back(query(l, r, i));
  }
  sort(Q.begin(), Q.end());
  ta.Init(n);
  int idx = E.size() - 1;
  for (int i = m - 1; i >= 0; i--) {
    while (idx >= 0 && E[idx].first >= Q[i].l) {
      ta.add(E[idx].second, 1);
      idx--;
    }
    ans[Q[i].idx] = ta.get(Q[i].r);
  }
  for (int i = 0; i < m; i++) printf("%d\n", ans[i]);
  return 0;
}
