#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int N = 2e5 + 4;
int n, m, p[N], idx[N];
LL v1[N], v2[N];
vector<int> vals[N];
struct BIT {
  int s[N];
  void init() { memset(s, 0, sizeof(s)); }
  void add(int i, int v) {
    for (; i <= n; i += i & (-i)) s[i] += v;
  }
  LL get(int i) {
    LL sum = 0;
    for (; i; i -= i & (-i)) sum += s[i];
    return sum;
  }
} bit;
struct E {
  int id, wh, v;
  E() = default;
  E(int _id, int _wh, int _v) : id(_id), wh(_wh), v(_v) {}
  bool operator<(const E &rhs) const { return wh < rhs.wh; }
};
struct Q {
  int l, r;
} qs[N];
vector<E> events;
int main() {
  bit.init();
  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 <= n; i++) {
    if (!idx[i]) continue;
    int ii = idx[i];
    for (int j = i; j <= n; j += i) {
      if (int ij = idx[j]) vals[ij].push_back(ii);
    }
  }
  events.reserve(2 * m);
  for (int i = 1; i <= m; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    if (l > 1) events.emplace_back(i, l - 1, 1);
    if (r <= n) events.emplace_back(i, r, 2);
    qs[i].l = l;
    qs[i].r = r;
  }
  sort(events.begin(), events.end());
  for (int i = 1, j = 0, es = events.size(); i <= n && j < es; i++) {
    for (int v : vals[i]) bit.add(v, 1);
    for (; j < es && events[j].wh == i; j++) {
      if (events[j].v == 1)
        v1[events[j].id] =
            bit.get(qs[events[j].id].r) - bit.get(qs[events[j].id].l - 1);
      else
        v2[events[j].id] =
            bit.get(qs[events[j].id].r) - bit.get(qs[events[j].id].l - 1);
    }
  }
  for (int i = 1; i <= m; i++) {
    printf("%lld\n", v2[i] - v1[i]);
  }
}
