#include <bits/stdc++.h>
using namespace std;
const int MAX = 200 * 1000 + 1;
int BIT[MAX];
void add(int i, int v) {
  for (; i < MAX; i += i & -i) BIT[i] += v;
}
int sum(int i) {
  int s = 0;
  for (; i; i -= i & -i) s += BIT[i];
  return s;
}
int n, m;
int A[MAX], B[MAX], X[MAX], Y[MAX], Q[MAX + MAX], R[MAX];
vector<int> divisors[MAX], multiples[MAX];
bool cmp(int a, int b) {
  int ea = a <= n ? a : Y[a - n];
  int eb = b <= n ? b : Y[b - n];
  return ea != eb ? ea < eb : a < b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = i + i; j <= n; j += i) {
      divisors[j].push_back(i);
      multiples[i].push_back(j);
    }
  }
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    B[A[i]] = i;
  }
  for (int i = 1; i <= m; i++) {
    cin >> X[i] >> Y[i];
  }
  for (int i = 1; i <= n + m; i++) {
    Q[i] = i;
  }
  sort(Q + 1, Q + n + m + 1, cmp);
  for (int i = 1; i <= n + m; i++) {
    if (Q[i] <= n) {
      int index = Q[i];
      int value = A[Q[i]];
      add(index, 1);
      for (size_t j = 0; j < divisors[value].size(); j++) {
        int div = divisors[value][j];
        if (B[div] < index) {
          add(B[div], 1);
        }
      }
      for (size_t j = 0; j < multiples[value].size(); j++) {
        int mul = multiples[value][j];
        if (B[mul] < index) {
          add(B[mul], 1);
        }
      }
    } else {
      R[Q[i] - n] = sum(Y[Q[i] - n]) - sum(X[Q[i] - n] - 1);
    }
  }
  for (int i = 1; i <= m; i++) {
    cout << R[i] << endl;
  }
  return 0;
}
