#include <bits/stdc++.h>
using namespace std;
const int N = 200 * 1000 + 85;
int n, m;
int a[N];
vector<int> vec[N];
pair<pair<int, int>, int> b[N];
int mapp[N];
int ans[N];
int seg[N << 2];
inline void add(int, int, int = 1, int = 0, int = N);
inline int get(int, int = 1, int = 0, int = N);
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mapp[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    int j = 1;
    while (j * i <= n) {
      if (mapp[j * i] >= mapp[i]) vec[mapp[j * i]].push_back(mapp[i]);
      if (mapp[i] > mapp[j * i]) vec[mapp[i]].push_back(mapp[j * i]);
      j++;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i].first.second >> b[i].first.first;
    b[i].first.second--;
    b[i].first.first--;
    b[i].second = i;
  }
  sort(b, b + m);
  int k = 0;
  for (int t = 0; t < m; t++) {
    while (k <= b[t].first.first) {
      for (int i = 0; i < vec[k].size(); i++) add(0, vec[k][i] + 1);
      k++;
    }
    ans[b[t].second] = get(b[t].first.second);
  }
  for (int i = 0; i < m; i++) cout << ans[i] << '\n';
}
inline void add(int st, int en, int id, int l, int r) {
  if (en <= l or r <= st) return;
  if (st <= l and r <= en) {
    seg[id]++;
    return;
  }
  int mid = (l + r) >> 1, lc = id << 1, rc = lc | 1;
  add(st, en, lc, l, mid);
  add(st, en, rc, mid, r);
}
inline int get(int idx, int id, int l, int r) {
  if (idx < l or r <= idx) return 0;
  if (l + 1 == r) return seg[id];
  int mid = (l + r) >> 1, lc = id << 1, rc = lc | 1;
  return get(idx, lc, l, mid) + get(idx, rc, mid, r) + seg[id];
}
