#include <bits/stdc++.h>
const int nmax = 2e5 + 5;
std::pair<std::pair<int, int>, int> qu[nmax];
int aib[nmax], v[nmax], m[nmax], n, q, ans[nmax];
std::vector<std::pair<int, int> > a;
int query(int first) {
  int ans = 0;
  for (int i = first; i; i -= (i & (-i))) ans += aib[i];
  return ans;
}
void update(int first, int second) {
  for (int i = first; i <= nmax; i += (-i) & i) aib[i] += second;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.tie(0);
  std::cin >> n >> q;
  for (int i = 1; i <= n; i++) std::cin >> v[i], m[v[i]] = i;
  std::sort(v + 1, v + n + 1);
  for (int i = 1; i <= n; i++)
    for (int j = v[i]; j <= nmax; j += v[i])
      if (m[j] != 0) a.push_back({m[v[i]], m[j]});
  for (int i = 0; i < a.size(); i++)
    if (a[i].first > a[i].second) std::swap(a[i].first, a[i].second);
  std::sort(a.begin(), a.end());
  for (auto z : a) update(z.second, 1);
  for (int i = 1; i <= q; i++)
    std::cin >> qu[i].first.first >> qu[i].first.second, qu[i].second = i;
  std::sort(qu + 1, qu + q + 1);
  int cnt = 0;
  for (int i = 1; i <= q; i++) {
    while (cnt < a.size() and a[cnt].first < qu[i].first.first)
      update(a[cnt++].second, -1);
    ans[qu[i].second] = query(qu[i].first.second);
  }
  for (int i = 1; i <= q; i++) std::cout << ans[i] << "\n";
}
