#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
vector<int> L[MAXN], R[MAXN];
int c[MAXN], a[MAXN], b[MAXN], ans[MAXN], l[MAXN], r[MAXN];
inline int lowbit(int k) { return k & -k; }
void add(int x) {
  for (; x < MAXN; x += lowbit(x)) c[x]++;
}
int query(int x) {
  int s = 0;
  for (; x > 0; x -= lowbit(x)) s += c[x];
  return s;
}
int main() {
  int n, m, x, y;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]), b[a[i]] = i;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &l[i], &r[i]);
    L[l[i]].push_back(i);
    R[r[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < L[i].size(); j++)
      ans[L[i][j]] -= query(r[L[i][j]]) - query(i - 1);
    for (int j = a[i]; j <= n; j += a[i]) add(b[j]);
    for (int j = 0; j < R[i].size(); j++)
      ans[R[i][j]] += query(i) - query(l[R[i][j]] - 1);
  }
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}
