#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
template <typename first, typename second>
ostream& operator<<(ostream& os, const pair<first, second>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ",";
    os << *it;
  }
  return os << "]";
}
template <typename T>
ostream& operator<<(ostream& os, const multiset<T>& v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename first, typename second>
ostream& operator<<(ostream& os, const map<first, second>& v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
void faltu() { cerr << '\n'; }
template <typename T>
void faltu(T a[], int n) {
  for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
  cerr << '\n';
}
template <typename T, typename... hello>
void faltu(T arg, const hello&... rest) {
  cerr << arg << ' ';
  faltu(rest...);
}
const int mx = 2e5 + 5;
int n, m;
int p[mx], rev[mx];
vector<int> vec[mx];
vector<pair<int, int> > q[mx];
int ans[mx];
int tree[mx * 4];
void update(int node, int l, int r, int b, int x) {
  if (l == r) {
    tree[node] += x;
    return;
  }
  int mid = (l + r) / 2;
  if (mid >= b)
    update(2 * node, l, mid, b, x);
  else
    update(2 * node + 1, mid + 1, r, b, x);
  tree[node] = tree[2 * node] + tree[2 * node + 1];
}
int query(int node, int l, int r, int b, int e) {
  if (l > e || r < b) return 0;
  if (l >= b && r <= e) return tree[node];
  int mid = (l + r) / 2;
  return query(2 * node, l, mid, b, e) + query(2 * node + 1, mid + 1, r, b, e);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
    rev[p[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; j += i) {
      int u = rev[i], v = rev[j];
      if (u > v) swap(u, v);
      vec[v].push_back(u);
    }
  }
  for (int i = 0; i < m; ++i) {
    int l, r;
    cin >> l >> r;
    q[r].push_back(make_pair(l, i));
  }
  for (int i = 1; i <= n; ++i) {
    while (!vec[i].empty()) {
      update(1, 1, n, vec[i].back(), 1);
      vec[i].pop_back();
    }
    while (!q[i].empty()) {
      pair<int, int> p = q[i].back();
      q[i].pop_back();
      int l = p.first, r = i, idx = p.second;
      ans[idx] = query(1, 1, n, l, r);
    }
  }
  for (int i = 0; i < m; ++i) cout << ans[i] << '\n';
}
