#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void sc(T &x) {
  register int c = getchar();
  x = 0;
  int neg = 0;
  for (; ((c<48 | c> 57) && c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x = -x;
}
template <class T>
inline T bigmod(T p, T e, T M) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
const int N = 2e5 + 5;
vector<int> L[N];
vector<pair<int, int> > V;
vector<pair<int, int> > Q[N];
long long A[N];
long long bit[N];
int n;
int pos[N];
long long ans[N];
void update(int x, int val) {
  while (x > 0) {
    bit[x] += val;
    x -= x & -x;
  }
}
long long query(int x) {
  long long res = 0;
  while (x <= n) {
    res += bit[x];
    x += x & -x;
  }
  return res;
}
int main() {
  sc(n);
  int m;
  sc(m);
  for (int i = (1); i < (n + 1); i++) {
    sc(A[i]);
    pos[A[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    int a = A[i];
    for (int b = a; b <= n; b += a) {
      int pp = pos[b];
      L[((i) > (pp) ? (i) : (pp))].push_back((((i) > (pp) ? (pp) : (i))));
      V.push_back((make_pair(i, pp)));
    }
  }
  for (int i = 0; i < m; i++) {
    int l, r;
    sc(l);
    sc(r);
    Q[r].push_back((make_pair(l, i)));
  }
  for (int i = 1; i <= n; i++) {
    for (auto a : L[i]) update(a, 1);
    for (auto a : Q[i]) {
      int l = a.first;
      int iv = a.second;
      ans[iv] = query(l);
    }
  }
  for (int i = 0; i < m; i++) printf("%lld\n", ans[i]);
}
