#include <bits/stdc++.h>
using namespace std;
const int MAXN = int(2e5) + 1;
int bt[MAXN], ans[MAXN];
int A[MAXN], N, M, pos[MAXN];
struct datapos {
  vector<pair<int, int>> qR;
  vector<pair<int, int>> qL;
} d[MAXN];
int getsum(int index) {
  unsigned sum = 0;
  while (index > 0) {
    sum += bt[index];
    index -= index & (-index);
  }
  return sum;
}
void incr(int index) {
  while (index <= N) {
    bt[index]++;
    index += index & (-index);
  }
}
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; i++) {
    scanf("%d", A + i);
    pos[A[i]] = i;
  }
  for (int queryi = 0, left, right; queryi < M; queryi++) {
    scanf("%d%d", &left, &right);
    d[right].qR.push_back({left, queryi});
    d[left].qL.push_back({right, queryi});
  }
  for (int posi = 1; posi <= N; posi++) {
    for (auto qu : d[posi].qL)
      ans[qu.second] -= (getsum(qu.first) - getsum(posi - 1));
    for (int x = A[posi]; x <= N; x += A[posi]) incr(pos[x]);
    for (auto qu : d[posi].qR)
      ans[qu.second] += (getsum(posi) - getsum(qu.first - 1));
  }
  for (int i = 0; i < M; i++) printf("%d\n", ans[i]);
  return 0;
}
