#include <bits/stdc++.h>
using namespace std;
int II() {
  int q;
  scanf("%d", &q);
  return q;
}
long long LII() {
  long long q;
  scanf("%lld", &q);
  return q;
}
const long long Mx = 200005;
vector<long long> v[Mx], pa[Mx];
vector<pair<long long, long long>> vv[Mx];
long long tree[Mx];
long long ar[Mx], br[Mx];
void update(long long in) {
  while (in < Mx) {
    tree[in] += 1, in += (in & (-in));
  }
}
long long query(long long in) {
  long long sum = 0;
  while (in > 0) {
    sum += tree[in], in -= (in & (-in));
  }
  return sum;
}
void solve() {
  for (long long i = 1; i < Mx; i++) {
    for (long long j = i; j < Mx; j += i) {
      v[j].push_back(i);
    }
  }
  long long N, M;
  cin >> N >> M;
  for (long long i = 1; i <= N; i++) {
    scanf("%lld", &ar[i]);
    br[ar[i]] = i;
  }
  for (long long i = 1; i <= M; i++) {
    long long l, r;
    cin >> l >> r;
    vv[r].push_back({l, i});
  }
  vector<pair<long long, long long>> ans;
  for (long long i = 1; i <= N; i++) {
    for (auto it : v[ar[i]]) {
      long long j = br[it];
      long long k = i;
      if (j > k) swap(j, k);
      pa[k].push_back(j);
    }
  }
  for (long long i = 1; i <= N; i++) {
    for (auto it : pa[i]) {
      update(it);
    }
    for (auto it : vv[i]) {
      ans.push_back({it.second, query(i) - query(it.first - 1)});
    }
  }
  sort(ans.begin(), ans.end());
  for (auto it : ans) printf("%lld\n", it.second);
}
int32_t main() {
  long long tt;
  tt = 1;
  long long cas = 1;
  while (tt--) {
    solve();
  }
}
