#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long A[N], idx[N], ans[N], BIT[N];
vector<long long> in[N], out[N];
vector<pair<long long, long long> > ss[N], se[N];
void update(long long idx, long long val) {
  for (; idx < N; idx += (idx & -idx)) BIT[idx] += val;
  return;
}
long long query(long long idx) {
  long long ret = 0;
  for (; idx > 0; idx -= (idx & -idx)) ret += BIT[idx];
  return ret;
}
int main() {
  long long n, m;
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; ++i) scanf("%lld", &A[i]), idx[A[i]] = i;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = A[i]; j <= n; j += A[i]) {
      long long st = idx[A[i]], en = idx[j];
      if (st > en) swap(st, en);
      in[st].push_back(en);
      out[en].push_back(en);
    }
  }
  for (long long i = 1; i <= m; ++i) {
    long long l, r;
    scanf("%lld%lld", &l, &r);
    se[l].push_back({r, i});
    ss[r].push_back({l, i});
  }
  for (long long i = 1; i <= n; ++i) {
    for (auto u : se[i]) ans[u.second] = -query(u.first);
    for (auto u : in[i]) update(u, 1);
    for (auto u : ss[i]) ans[u.second] += query(i);
  }
  for (long long i = 1; i <= m; ++i) printf("%lld\n", ans[i]);
  return 0;
}
