#include <bits/stdc++.h>
using namespace std;
int n, m, a[200010], t[200010], pos[200010], ans[200010];
struct point {
  int pos, v, f;
  point(int pos, int v, int f) : pos(pos), v(v), f(f) {}
};
vector<point> v[200010];
inline void insert(int x) {
  for (register int i = x; i <= n; i += i & -i) t[i]++;
}
inline int find(int x) {
  register int ans = 0;
  for (register int i = x; i; i -= i & -i) ans += t[i];
  return ans;
}
inline void add(int x, int y, int f, int i) { v[x].push_back(point(i, y, f)); }
inline int read() {
  register int x = 0, ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x;
}
int main() {
  n = read(), m = read();
  for (register int i = 1; i <= n; i++) pos[a[i] = read()] = i;
  for (register int i = 1; i <= m; i++) {
    int l = read(), r = read();
    add(r, r, 1, i), add(l - 1, r, -1, i), add(r, l - 1, -1, i),
        add(l - 1, l - 1, 1, i);
  }
  for (register int i = 1; i <= n; i++) {
    for (register int j = a[i]; j <= n; j += a[i]) insert(pos[j]);
    for (register int j = 0; j < v[i].size(); j++)
      ans[v[i][j].pos] += find(v[i][j].v) * v[i][j].f;
  }
  for (register int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}
