#include <bits/stdc++.h>
using namespace std;
const long long linf = 1e18 + 9;
const int inf = 1e9 + 9;
const int N = 2e5 + 9;
int n, q, l[N], r[N], a[N], wh[N];
long long bit[N], ans[N];
vector<int> h[N];
vector<pair<int, int> > Q[N];
void update(int t) {
  t++;
  while (t <= n + 1) {
    bit[t]++;
    t += (t & -t);
  }
}
long long query(int t) {
  long long sum = 0;
  t++;
  while (t > 0) {
    sum += bit[t];
    t -= (t & -t);
  }
  return sum;
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    wh[a[i]] = i;
  }
  for (int i = 1; i <= q; i++) {
    scanf("%d %d", &l[i], &r[i]);
    Q[r[i]].push_back(make_pair(l[i], i));
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      h[j].push_back(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < h[a[i]].size(); j++) {
      if (wh[h[a[i]][j]] <= i) {
        update(wh[h[a[i]][j]]);
      }
    }
    for (int j = a[i] * 2; j <= n; j += a[i]) {
      if (wh[j] < i) {
        update(wh[j]);
      }
    }
    for (int j = 0; j < Q[i].size(); j++) {
      ans[Q[i][j].second] += query(i) - query(Q[i][j].first - 1);
    }
  }
  for (int i = 1; i <= q; i++) {
    printf("%lld\n", ans[i]);
  }
  return 0;
}
