#include <bits/stdc++.h>
using namespace std;
struct query {
  int l, r, id;
} Q[201010];
int n, m, v[201010], f[201010];
long long bit[201010], answer[201010];
vector<int> d[201010];
void calc(int x) {
  for (int i = 1; i * 1LL * i <= x; i++) {
    if (x % i) continue;
    if (i * 1LL * i != x) d[x].push_back(x / i);
    d[x].push_back(i);
  }
}
void update(int pos, int val) {
  for (; pos <= n; pos += pos & (-pos)) bit[pos] += val;
}
long long sum(int pos) {
  long long s = 0;
  for (; pos; pos -= pos & (-pos)) s += bit[pos];
  return s;
}
void add(int x, int p) {
  f[x] = p;
  for (int a : d[x]) {
    if (f[a]) update(f[a], 1);
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &v[i]);
    calc(v[i]);
  }
  for (int i = 0; i < m; i++) {
    Q[i].id = i;
    scanf("%d %d", &Q[i].l, &Q[i].r);
    answer[i] = -(Q[i].r - Q[i].l + 1);
  }
  sort(Q, Q + m, [](query a, query b) { return a.r < b.r; });
  int p = 1;
  for (int i = 0; i < m; i++) {
    while (p <= Q[i].r) add(v[p], p), p++;
    answer[Q[i].id] += sum(Q[i].r) - sum(Q[i].l - 1);
  }
  sort(Q, Q + m, [](query a, query b) { return a.l > b.l; });
  memset(f, 0, sizeof f);
  memset(bit, 0, sizeof bit);
  p = n;
  for (int i = 0; i < m; i++) {
    while (p >= Q[i].l) add(v[p], p), p--;
    answer[Q[i].id] += sum(Q[i].r) - sum(Q[i].l - 1);
  }
  for (int i = 0; i < m; i++) printf("%lld\n", answer[i]);
}
