#include <bits/stdc++.h>
using namespace std;
const static int inf = 0x3f3f3f3f;
const static int maxn = 2e5 + 10;
int n, m;
int a[maxn];
vector<int> ll[maxn];
vector<int> rr[maxn];
int l[maxn], r[maxn];
int p[maxn];
int tree[maxn];
int lowbit(int x) { return x & (-x); }
void add(int x) {
  for (int i = x; i <= n; i += lowbit(i)) tree[i]++;
}
int query(int x) {
  int ret = 0;
  for (int i = x; i >= 1; i -= lowbit(i)) ret += tree[i];
  return ret;
}
int ans[maxn];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    p[a[i]] = i;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &l[i], &r[i]);
    ll[l[i]].push_back(i);
    rr[r[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < ll[i].size(); j++)
      ans[ll[i][j]] -= query(r[ll[i][j]]) - query(i - 1);
    for (int j = 1; j * a[i] <= n; j++) add(p[a[i] * j]);
    for (int j = 0; j < rr[i].size(); j++)
      ans[rr[i][j]] += query(i) - query(l[rr[i][j]] - 1);
  }
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}
