#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int v, next;
} edge[3000005];
int head[200005], e;
inline void addedge(int u, int v) {
  edge[e].v = v;
  edge[e].next = head[u];
  head[u] = e++;
}
long long num[200005 << 2];
long long lazy[200005 << 2];
long long ans[200005];
int value[200005];
int pos[200005];
struct node {
  int l, r, pos;
  bool operator<(node temp) const { return r < temp.r; }
} data[200005];
inline void pushdown(int rt) {
  if (lazy[rt]) {
    num[rt << 1] += lazy[rt];
    num[rt << 1 | 1] += lazy[rt];
    lazy[rt << 1] += lazy[rt];
    lazy[rt << 1 | 1] += lazy[rt];
    lazy[rt] = 0;
  }
}
inline void update(int L, int R, int l, int r, int rt, int v) {
  if (L <= l && r <= R) {
    num[rt] += v;
    lazy[rt] += v;
    return;
  }
  pushdown(rt);
  int m = (l + r) >> 1;
  if (L <= m) update(L, R, l, m, rt << 1, v);
  if (R > m) update(L, R, m + 1, r, rt << 1 | 1, v);
}
inline long long query(int p, int l, int r, int rt) {
  if (l == r) return num[rt];
  pushdown(rt);
  int m = (l + r) >> 1;
  if (p <= m)
    return query(p, l, m, rt << 1);
  else
    return query(p, m + 1, r, rt << 1 | 1);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  e = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &value[i]);
    pos[value[i]] = i;
    head[i] = -1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j * j <= value[i]; j++) {
      if (value[i] % j == 0) {
        if (pos[j] <= pos[value[i]]) addedge(value[i], j);
        if (value[i] != j && pos[value[i]] <= pos[j]) addedge(j, value[i]);
        if (j * j == value[i]) continue;
        int k = value[i] / j;
        if (pos[k] <= pos[value[i]]) addedge(value[i], k);
        if (value[i] != k && pos[value[i]] <= pos[k]) addedge(k, value[i]);
      }
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &data[i].l, &data[i].r);
    data[i].pos = i;
  }
  sort(data, data + m);
  int p = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = head[value[i]]; j != -1; j = edge[j].next) {
      int k = edge[j].v;
      update(1, pos[k], 1, n, 1, 1);
    }
    while (data[p].r == i && p < m) {
      ans[data[p].pos] = query(data[p].l, 1, n, 1);
      p++;
    }
  }
  for (int i = 0; i < m; i++) {
    printf("%I64d\n", ans[i]);
  }
}
