#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
int C[200005];
int lowbit(int x) { return x & (-x); }
void update(int x, int v) {
  while (x < 200005) {
    C[x] += v;
    x += lowbit(x);
  }
}
int sum(int x) {
  int res = 0;
  while (x > 0) {
    res += C[x];
    x -= lowbit(x);
  }
  return res;
}
int n, m;
int val[200005];
struct node {
  int L, R, id;
} e[200005], e1[200005];
bool cmp(node a, node b) { return a.R < b.R; }
bool cmp1(node a, node b) { return a.L < b.L; }
int ans[200005];
int pre[200005];
void Init() {
  memset(pre, 0, sizeof pre);
  memset(C, 0, sizeof C);
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    Init();
    for (int i = 1; i <= n; i++) {
      scanf("%d", &val[i]);
      pre[val[i]] = i;
    }
    for (int i = 0; i < m; i++) {
      scanf("%d%d", &e[i].L, &e[i].R);
      e[i].id = i;
      e1[i] = e[i];
    }
    sort(e, e + m, cmp);
    sort(e1, e1 + m, cmp1);
    int k = 0, k1 = 0;
    for (int i = 1; i <= n; i++) {
      while (k1 < m && e1[k1].L == i) {
        ans[e1[k1].id] -= sum(e1[k1].R) - sum(e1[k1].L - 1);
        k1++;
      }
      for (long long j = val[i]; j <= n; j += val[i]) update(pre[j], 1);
      while (k < m && e[k].R == i) {
        ans[e[k].id] += sum(e[k].R) - sum(e[k].L - 1);
        k++;
      }
    }
    for (int i = 0; i < m; i++) printf("%d\n", ans[i]);
  }
  return 0;
}
