#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5;
struct node {
  int l, r, id;
} q[maxn + 10];
int a[maxn + 10];
int ans[maxn + 10];
int inx[maxn + 10];
int c[maxn + 10];
int lowbit(int x) { return x & (-x); }
int sum(int x) {
  int res = 0;
  while (x > 0) {
    res += c[x];
    x -= lowbit(x);
  }
  return res;
}
void add(int x, int val) {
  while (x <= maxn) {
    c[x] += val;
    x += lowbit(x);
  }
}
bool cmp(node a, node b) { return a.r < b.r; }
vector<int> ve[maxn + 10];
int main() {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    memset(c, 0, sizeof(c));
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      inx[a[i]] = i;
      ve[i].clear();
    }
    for (int i = 1; i <= n; i++) {
      for (int j = i + i; j <= n; j += i) {
        int idi = inx[i];
        int idj = inx[j];
        if (idj > idi) {
          ve[idj].push_back(idi);
        } else {
          ve[idi].push_back(idj);
        }
      }
    }
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &q[i].l, &q[i].r);
      q[i].id = i;
    }
    sort(q + 1, q + m + 1, cmp);
    int r = 1;
    for (int i = 1; i <= m; i++) {
      while (r <= q[i].r) {
        for (auto id : ve[r]) {
          add(id, 1);
        }
        r++;
      }
      ans[q[i].id] = sum(q[i].r) - sum(q[i].l - 1) + q[i].r - q[i].l + 1;
    }
    for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  }
  return 0;
}
