#include <bits/stdc++.h>
using namespace std;
const int64_t N = 2e5 + 10;
int64_t n, m, a[N], first[N], ans[N], p[N];
pair<std::pair<int64_t, int64_t>, int64_t> q[N];
vector<int64_t> adj[N];
void add(int64_t x, int64_t y) {
  for (; x < N; x += x & -x) {
    first[x] += y;
  }
}
int64_t get(int64_t x) {
  int64_t ret = 0;
  for (; x; x -= x & -x) {
    ret += first[x];
  }
  return ret;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int64_t i = 1; i <= n; i++) {
    cin >> a[i];
    p[a[i]] = i;
  }
  for (int64_t i = 1; i <= n; i++) {
    for (int64_t j = i; j <= n; j += i) {
      adj[min(p[i], p[j])].push_back(max(p[i], p[j]));
      add(max(p[i], p[j]), 1ll);
    }
  }
  for (int64_t i = 0; i < m; i++) {
    cin >> q[i].first.first >> q[i].first.second;
    q[i].second = i;
  }
  sort(q, q + m);
  int64_t last = 1;
  for (int64_t i = 0; i < m; i++) {
    while (last < q[i].first.first) {
      for (int64_t k = 0; k < adj[last].size(); k++) {
        add(adj[last][k], -1ll);
      }
      last++;
    }
    ans[q[i].second] = get(q[i].first.second);
  }
  for (int64_t i = 0; i < m; i++) {
    cout << ans[i] << '\n';
  }
}
