#include <bits/stdc++.h>
using namespace std;
template <typename T>
T nextInt() {
  T x = 0, p = 1;
  char ch;
  do {
    ch = getchar();
  } while (ch <= ' ');
  if (ch == '-') {
    p = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * p;
}
const int maxN = (int)2e5 + 10;
const int INF = (int)1e9;
const int mod = (int)1e9 + 7;
const long long LLINF = (long long)1e18;
int n, q;
int a[maxN];
int p[maxN];
vector<int> segments[maxN];
int fw[maxN];
void add(int r) {
  for (; r < maxN; r |= r + 1) {
    fw[r]++;
  }
}
int get(int r) {
  int ret = 0;
  for (; r >= 0; r = (r & (r + 1)) - 1) {
    ret += fw[r];
  }
  return ret;
}
vector<pair<int, int> > queries[maxN];
int answer[maxN];
int main() {
  n = nextInt<int>();
  q = nextInt<int>();
  for (int i = 0; i < n; ++i) {
    a[i] = nextInt<int>();
    p[a[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = a[i]; j <= n; j += a[i]) {
      int l = i;
      int r = p[j];
      if (l > r) swap(l, r);
      segments[l].push_back(r);
    }
  }
  for (int qq = 0; qq < q; ++qq) {
    int l, r;
    l = nextInt<int>() - 1;
    r = nextInt<int>() - 1;
    queries[l].push_back(make_pair(r, qq));
  }
  for (int l = n - 1; l >= 0; --l) {
    for (int r : segments[l]) {
      add(r);
    }
    for (auto q : queries[l]) {
      answer[q.second] = get(q.first);
    }
  }
  for (int i = 0; i < q; ++i) {
    printf("%d\n", answer[i]);
  }
  return 0;
}
