#include <bits/stdc++.h>
using namespace std;
const int MAXN = int(2e5) + 1;
unsigned bt[MAXN], ans[MAXN];
int A[MAXN], N, M, pos[MAXN];
struct datapos {
  stack<pair<int, int>> q;
  stack<int> lefties;
} d[MAXN];
unsigned getsum(int index) {
  unsigned sum = 0;
  while (index > 0) {
    sum += bt[index];
    index -= index & (-index);
  }
  return sum;
}
void incr(int index, int val = 1) {
  while (index <= N) {
    bt[index] += val;
    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].q.push({left, queryi});
  }
  for (int num = 1; num <= N; num++) {
    for (int multi = 2 * num; multi <= N; multi += num) {
      int left = min(pos[num], pos[multi]);
      int right = max(pos[num], pos[multi]);
      d[right].lefties.push(left);
    }
  }
  for (int posi = 1; posi <= N; posi++) {
    while (!d[posi].lefties.empty()) {
      incr(d[posi].lefties.top());
      d[posi].lefties.pop();
    }
    while (!d[posi].q.empty()) {
      pair<int, int>& qu = d[posi].q.top();
      ans[qu.second] =
          getsum(posi) - getsum(qu.first - 1) + (posi - qu.first + 1);
      d[posi].q.pop();
    }
  }
  for (int i = 0; i < M; i++) printf("%u\n", ans[i]);
  return 0;
}
