#include <bits/stdc++.h>
using namespace std;
int ans[200005], pos[200005], a[200005], c[200005];
int n, m;
struct node {
  int i, l, r;
  bool operator<(const node &a) const { return l < a.l; }
} es[200005], et[200005];
int lowbit(int x) { return x & (-x); }
void update(int x) {
  int i;
  for (i = x; i <= n; i += lowbit(i)) c[i]++;
}
int getsum(int x) {
  int i, sum = 0;
  for (i = x; i > 0; i -= lowbit(i)) sum += c[i];
  return sum;
}
void init() {
  scanf("%d%d", &n, &m);
  int i;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    pos[a[i]] = i;
  }
  int j, k;
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &j, &k);
    es[i].i = i, es[i].l = j, es[i].r = k;
    et[i].i = i, et[i].l = k, et[i].r = j;
  }
  sort(es + 1, es + 1 + m);
  sort(et + 1, et + 1 + m);
}
void solve() {
  int i, j, k, p;
  for (i = j = k = 1; i <= n; i++) {
    for (; j <= m; j++) {
      if (es[j].l != i) break;
      ans[es[j].i] -= getsum(es[j].r) - getsum(es[j].l - 1);
    }
    for (p = a[i]; p <= n; p += a[i]) update(pos[p]);
    for (; k <= m; k++) {
      if (et[k].l != i) break;
      ans[et[k].i] += getsum(et[k].l) - getsum(et[k].r - 1);
    }
  }
  for (i = 1; i <= m; i++) {
    printf("%d\n", ans[i]);
  }
}
int main() {
  init();
  solve();
  return 0;
}
