#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
long long a, cn, b, cnn = 1, c, ans[200007], T[200007 * 2], d[200007], n, m;
vector<long long> rr[200007];
vector<long long> q[200007];
vector<pair<int, int> > rt[200007];
void upd(long long x) {
  for (; x; x -= (long long)(-x & x)) T[x]++;
}
long long tek(long long x) {
  if (x == 0) return 0;
  long long sum = 0;
  for (; x <= n; x += (long long)(-x & x)) sum += T[x];
  return sum;
}
long long bul(long long x, long long y) { return tek(x) - tek(y + 1); }
int main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; i++)
    scanf("%lld", d + i), rr[d[i]].push_back(i);
  for (long long i = 1; i <= n; i++) {
    for (long long j = d[i]; j <= n; j += d[i])
      for (long long h : rr[j]) q[max(i, h)].push_back(min(i, h));
  }
  for (long long i = 1; i <= m; i++) {
    scanf("%lld%lld", &a, &b);
    rt[b].push_back({a, i});
  }
  for (long long i = 1; i <= n; i++) {
    for (int h : q[i]) upd(h);
    for (pair<long long, long long> h : rt[i]) ans[h.second] = bul(h.first, i);
  }
  for (long long i = 1; i <= m; i++) printf("%lld\n", ans[i]);
  return 0;
}
