#include <bits/stdc++.h>
using namespace std;
int const N = 2e5 + 5;
vector<int> divisors[N];
vector<int> multi[N];
int l[N], r[N];
int occur[N];
struct Compare {
  bool operator()(const vector<int>& m, const vector<int>& n) {
    if (m[1] != n[1])
      return m[1] < n[1];
    else if (m[2] != n[2])
      return m[2] < n[2];
  }
};
set<vector<int>, Compare> intervals;
int n, m;
int p[N];
using ll = long long;
ll ans[N];
ll t[N];
void update(int x, int val) {
  for (int i = x; i < n + 2; i += (i & -i)) t[i] += val;
}
ll query(int k) {
  ll an = 0;
  for (int i = k; i > 0; i -= (i & -i)) an += t[i];
  return an;
}
ll query(int a, int b) { return query(b) - query(a - 1); }
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
    occur[p[i]] = i;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &l[i], &r[i]);
    intervals.insert({l[i], r[i], i});
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 2 * i; j <= n; j += i) {
      divisors[j].push_back(i);
      multi[i].push_back(j);
    }
  }
  auto it = intervals.begin();
  for (int i = 1; i <= n; i++) {
    for (int k = 0; k < divisors[p[i]].size(); k++) {
      int u = divisors[p[i]][k];
      if (occur[u] < i) {
        update(occur[u], 1);
      }
    }
    for (int k = 0; k < multi[p[i]].size(); k++) {
      int u = multi[p[i]][k];
      if (occur[u] < i) {
        update(occur[u], 1);
      }
    }
    while ((*it)[1] == i) {
      ans[(*it)[2]] = query((*it)[0], (*it)[1]) + (*it)[1] - (*it)[0] + 1;
      it++;
      if (it == intervals.end()) break;
    }
    if (it == intervals.end()) break;
  }
  for (int i = 1; i <= m; i++) {
    printf("%I64d \n", ans[i]);
  }
  return 0;
}
