#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 2;
struct TSeg {
  int l, r;
};
struct TQuery {
  int l, r, id;
};
int n, m, b[N], res[N];
vector<TSeg> a;
vector<TQuery> p;
void Prep() {
  vector<int> p(n + 1);
  for (int i = 1; i <= n; ++i) p[b[i]] = i;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; i * j <= n; ++j) {
      int l = p[i], r = p[i * j];
      if (l > r) swap(l, r);
      a.push_back({l, r});
    }
}
class TBTree {
  int bit[N];

 public:
  void Update(int id) {
    for (; id > 0; id -= id & -id) ++bit[id];
  }
  int Query(int id) {
    int sum = 0;
    for (; id <= n; id += id & -id) sum += bit[id];
    return sum;
  }
} tree;
void Solve() {
  sort(a.begin(), a.end(), [](TSeg a, TSeg b) { return a.r < b.r; });
  sort(p.begin(), p.end(), [](TQuery a, TQuery b) { return a.r < b.r; });
  auto upd = a.begin();
  auto itq = p.begin();
  for (int i = 1; i <= n; ++i) {
    while (upd != a.end() && upd->r <= i) tree.Update((upd++)->l);
    while (itq != p.end() && itq->r <= i) {
      res[itq->id] = tree.Query(itq->l);
      ++itq;
    }
  }
  for (int i = 0; i < m; ++i) printf("%d\n", res[i]);
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &b[i]);
  for (int i = 0; i < m; ++i) {
    int l, r;
    scanf("%d %d", &l, &r);
    p.push_back({l, r, i});
  }
  Prep();
  Solve();
  return 0;
}
