#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5;
int n, m, A[maxn + 20], B[maxn + 20], r[maxn + 20], l[maxn + 20],
    Ans[maxn + 20], fen[maxn + 20];
map<pair<int, int>, int> M;
vector<int> joft[maxn + 20], Q[maxn + 20];
void add(int x) {
  x++;
  for (int i = x; i < maxn + 20; i += (i & (-i))) {
    fen[i]++;
  }
}
int get(int x) {
  x++;
  int res = 0;
  for (int i = x; i; i -= (i & (-i))) {
    res += fen[i];
  }
  return res;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    B[A[i]] = i;
  }
  for (int i = 0; i < m; i++) {
    cin >> l[i] >> r[i];
    Q[l[i]].push_back(r[i]);
    M[{l[i], r[i]}] = i;
  }
  for (int i = 1; i <= n; i++) {
    int tmp = i;
    while (tmp <= n) {
      joft[min(B[i], B[tmp])].push_back(max(B[i], B[tmp]));
      tmp += i;
    }
  }
  for (int i = n; i > 0; i--) {
    for (int j = 0; j < joft[i].size(); j++) {
      add(n + 1 - joft[i][j]);
    }
    for (int j = 0; j < Q[i].size(); j++) {
      int res = get(n + 1 - i);
      res -= get(n - Q[i][j]);
      Ans[M[{i, Q[i][j]}]] = res;
    }
  }
  for (int i = 0; i < m; i++) {
    cout << Ans[M[{l[i], r[i]}]] << endl;
  }
  return 0;
}
