#include <bits/stdc++.h>
using namespace std;
struct Query {
  int p, id, l, r, fl;
  Query(int _p, int _id, int _l, int _r, int _fl) {
    p = _p;
    id = _id;
    l = _l;
    r = _r;
    fl = _fl;
  }
  bool operator<(const Query &B) const { return p < B.p; }
};
int N, M, P[200005], pos[200005], ans[200005], tree[200005];
vector<Query> vec;
int read(int id) {
  int sum = 0;
  while (id > 0) {
    sum += tree[id];
    id -= (id & -id);
  }
  return sum;
}
void update(int id, int v) {
  while (id < 200005) {
    tree[id] += v;
    id += (id & -id);
  }
}
int main() {
  scanf("%d", &N);
  scanf("%d", &M);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &P[i]);
    pos[P[i]] = i;
  }
  for (int i = 0; i < M; i++) {
    int l, r;
    scanf("%d", &l);
    scanf("%d", &r);
    if (l > 1) vec.push_back(Query(l - 1, i, l, r, -1));
    vec.push_back(Query(r, i, l, r, 1));
  }
  sort(vec.begin(), vec.end());
  int p = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = P[i]; j <= N; j += P[i]) update(pos[j], 1);
    while (p < vec.size() && vec[p].p == i) {
      ans[vec[p].id] += (vec[p].fl * (read(vec[p].r) - read(vec[p].l - 1)));
      p++;
    }
  }
  for (int i = 0; i < M; i++) printf("%d\n", ans[i]);
}
