#include <bits/stdc++.h>
using namespace std;
bool checkbitt(long long int num, int pos);
long long int setbitt(long long int num, long long int pos);
long long int resetbitt(long long int num, int pos);
const long long int mod = 1e9 + 7;
const long long int N = 2e5 + 100;
int idx[N];
int n, q;
int st[N * 4];
vector<int> graph[N];
void seive() {
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      graph[min(idx[i], idx[j])].push_back(max(idx[i], idx[j]));
    }
  }
}
void update(int n, int s, int e, int pos) {
  if (s == e) {
    st[n]++;
    return;
  }
  int mid = (s + e) / 2;
  if (mid >= pos)
    update(n * 2, s, mid, pos);
  else
    update(n * 2 + 1, mid + 1, e, pos);
  st[n] = st[n * 2] + st[n * 2 + 1];
}
int query(int n, int s, int e, int qs, int qe) {
  if (s > qe || e < qs) return 0;
  if (s >= qs && e <= qe) return st[n];
  int mid = (s + e) / 2;
  return query(n * 2, s, mid, qs, qe) + query(n * 2 + 1, mid + 1, e, qs, qe);
}
void U(int id, int v) {
  for (; id <= n; st[id] += v, id += (id & -id))
    ;
}
int Q(int id) {
  int ret = 0;
  for (; id > 0; ret += st[id], id -= (id & -id))
    ;
  return ret;
}
int solve() {
  cin >> n >> q;
  int x;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    idx[x] = i;
  }
  seive();
  vector<pair<int, int> > ask[n + 1];
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    ask[l].push_back({r, i});
  }
  int ans[q];
  for (int i = n; i >= 1; i--) {
    for (auto x : graph[i]) {
      U(x, 1);
    }
    for (auto x : ask[i]) {
      ans[x.second] = Q(x.first);
    }
  }
  for (int i = 0; i < q; i++) cout << ans[i] << endl;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int cs = 1;
  int cn = 1;
  while (cs--) {
    solve();
  }
}
bool checkbitt(long long int num, int pos) { return (num >> pos) & 1; }
long long int setbitt(long long int num, long long int pos) {
  return (1 << pos) | num;
}
long long int resetbitt(long long int num, int pos) {
  if (!checkbitt(num, pos))
    return num;
  else
    return (1 << pos) ^ num;
}
