#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n, m;
int a[maxn], pos[maxn], c[maxn], ans[maxn];
vector<int> v[maxn];
struct query {
  int id, x, y;
  friend bool operator<(query a, query b) { return a.x > b.x; }
} q[maxn];
int lowbit(int x) { return x & -x; }
int sum(int p) {
  int res = 0;
  while (p > 0) {
    res += c[p];
    p -= lowbit(p);
  }
  return res;
}
void add(int p, int val) {
  while (p <= n) {
    c[p] += val;
    p += lowbit(p);
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    pos[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = a[i]; j <= n; j += a[i]) {
      if (pos[j] >= i)
        v[i].push_back(pos[j]);
      else
        v[pos[j]].push_back(i);
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &q[i].x, &q[i].y);
    if (q[i].y < q[i].x) swap(q[i].x, q[i].y);
    q[i].id = i;
  }
  sort(q, q + m);
  int maxx = n + 1;
  for (int i = 0; i < m; i++) {
    int x = q[i].x, y = q[i].y, len;
    for (int j = x; j < maxx; j++) {
      len = v[j].size();
      for (int k = 0; k < len; k++) add(v[j][k], 1);
    }
    ans[q[i].id] = sum(y) - 0;
    maxx = x;
  }
  for (int i = 0; i < m; i++) printf("%d\n", ans[i]);
  return 0;
}
