#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200 * 1000 + 9;
const bool QRY = 0;
const bool UPD = 1;
struct Data {
  int l, r, id;
  Data() : l(0), r(0){};
  Data(int _l, int _r) : l(_l), r(_r){};
} a[MAX_N];
int n, m, N;
int p[MAX_N], idx[MAX_N];
long long fwt[MAX_N], ans[MAX_N];
vector<pair<long long, long long> > divP;
void treeUpdate(int idx, long long val) {
  for (; idx <= n; idx += (idx & -idx)) fwt[idx] += val;
}
long long sum(int idx) {
  long long total = 0;
  for (; idx > 0; idx -= (idx & -idx)) total += fwt[idx];
  return total;
}
long long treeSum(int l, int r) { return sum(r) - sum(l - 1); }
bool cmp(const Data &lhs, const Data &rhs) { return lhs.r < rhs.r; }
bool dCmp(const pair<long long, long long> &lhs,
          const pair<long long, long long> &rhs) {
  return lhs.second < rhs.second;
}
void gen() {
  for (int i = 1; i <= n; i++) {
    for (int pj = p[i]; pj <= n; pj += p[i]) {
      int j = idx[pj];
      divP.push_back(make_pair(i, j));
      if (divP.back().first > divP.back().second)
        swap(divP.back().first, divP.back().second);
    }
  }
}
void readInput() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
    idx[p[i]] = i;
  }
  for (int i = 1; i <= m; i++) {
    cin >> a[i].l >> a[i].r;
    a[i].id = i;
  }
}
void solve() {
  gen();
  sort(a + 1, a + m + 1, cmp);
  sort(divP.begin(), divP.end(), dCmp);
  N = divP.size();
  int j = 0;
  for (int i = 1; i <= m; i++) {
    while (j < N && divP[j].second <= a[i].r) {
      treeUpdate(divP[j].first, 1);
      j++;
    }
    ans[a[i].id] = treeSum(a[i].l, a[i].r);
  }
  for (int i = 1; i <= m; i++) cout << ans[i] << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  readInput();
  solve();
  return 0;
}
