#include <bits/stdc++.h>
using namespace std;
template <class T>
using v2d = vector<vector<T> >;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
const int maxN = 2e5 + 10;
int n, m, a[maxN], pos[maxN];
vector<int> divisors[maxN], multiples[maxN];
struct query {
  int l, r, idx;
  long long res;
  query() {}
  query(int l, int r, int idx) : l(l), r(r), idx(idx) {}
};
vector<query> q;
long long f[maxN];
void update(int x, long long d) {
  for (; x <= n; x += x & -x) {
    f[x] += d;
  }
}
long long prefix(int x) {
  long long r = 0;
  for (; x > 0; x &= x - 1) {
    r += f[x];
  }
  return r;
}
void init() {
  for (int i = 1; i <= (int)(n); ++i) {
    for (int j = i; j <= n; j += i) {
      divisors[j].emplace_back(i);
      multiples[i].emplace_back(j);
    }
  }
  for (int i = 1; i <= (int)(n); ++i) {
    sort((divisors[i]).begin(), (divisors[i]).end());
    sort((multiples[i]).begin(), (multiples[i]).end());
  }
}
void solve() {
  cin >> n >> m;
  init();
  for (int i = 1; i <= (int)(n); ++i) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  for (int i = 1; i <= (int)(m); ++i) {
    int l, r;
    cin >> l >> r;
    q.emplace_back(l, r, i);
  }
  sort((q).begin(), (q).end(), [](query x, query y) { return x.r < y.r; });
  int idx = 0;
  for (int i = 1; i <= (int)(n); ++i) {
    for (auto &div : divisors[a[i]]) {
      if (pos[div] <= i) {
        update(pos[div], 1);
      }
    }
    for (auto &mul : multiples[a[i]]) {
      if (pos[mul] < i) {
        update(pos[mul], 1);
      }
    }
    while (idx < m && q[idx].r <= i) {
      q[idx].res = prefix(q[idx].r) - prefix(q[idx].l - 1);
      ++idx;
    }
  }
  sort((q).begin(), (q).end(), [](query x, query y) { return x.idx < y.idx; });
  for (auto &qr : q) {
    cout << qr.res << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
