#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "{" << p.first << "," << p.second << "}";
  return os;
}
const int N = 2e5 + 5;
const int oo = 1e9 + 7;
int p[N];
int id[N];
int ans[N];
vector<pair<int, int> > q[N];
vector<int> del[N];
long long Tree[N];
void update(int idx, long long x, int n) {
  while (idx <= n) {
    Tree[idx] += x;
    idx += (idx & -idx);
  }
}
long long query(int idx) {
  long long sum = 0;
  while (idx > 0) {
    sum += Tree[idx];
    idx -= (idx & -idx);
  }
  return sum;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
    id[p[i]] = i;
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    q[x].push_back({y, i});
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      int x = id[i];
      int y = id[j];
      if (x > y) swap(x, y);
      del[x].push_back(y);
      update(y, 1, n);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (auto x : q[i]) {
      ans[x.second] = query(x.first);
    }
    for (auto x : del[i]) update(x, -1, n);
  }
  for (int i = 1; i <= m; i++) cout << ans[i] << "\n";
}
