#include <bits/stdc++.h>
using namespace std;
const int SIZE = 2e5 + 5;
int tree[SIZE], n, m, N, p[SIZE], indx[SIZE], res[SIZE];
pair<int, int> divP[18 * SIZE];
struct data {
  int u, v, p;
} queries[SIZE];
bool compare(const pair<int, int> &a, const pair<int, int> &b) {
  return a.second < b.second;
}
bool compareD(const data &a, const data &b) { return a.v < b.v; }
void Input() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
    indx[p[i]] = i;
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    queries[i] = {x, y, i};
  }
}
void make_Div_pair() {
  for (int i = 1; i <= n; i++) {
    for (int pj = p[i]; pj <= n; pj += p[i]) {
      int j = indx[pj];
      divP[++N] = (i < j) ? make_pair(i, j) : make_pair(j, i);
    }
  }
}
int sum(int u) {
  int temp = 0;
  for (; u > 0; u -= (u & -u)) temp += tree[u];
  return temp;
}
int get_sum(int u, int v) { return sum(v) - sum(u - 1); }
void update(int u, int val) {
  for (; u <= n; u += (u & -u)) tree[u] += val;
}
void Solve() {
  make_Div_pair();
  sort(divP + 1, divP + N + 1, compare);
  sort(queries + 1, queries + m + 1, compareD);
  int now = 1;
  for (int i = 1; i <= m; i++) {
    int u = queries[i].u;
    int v = queries[i].v;
    int p = queries[i].p;
    while (now <= N && divP[now].second <= v) {
      update(divP[now].first, 1);
      now++;
    }
    res[p] = get_sum(u, v);
  }
}
void Print() {
  for (int i = 1; i <= m; i++) cout << res[i] << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  Input();
  Solve();
  Print();
  return 0;
}
