#include <bits/stdc++.h>
using namespace std;
const int N = 2 * (1e5 + 5);
int t[N + 5];
int n;
int inde[N];
vector<vector<int>> pai(N);
vector<vector<pair<int, int>>> query(N);
int m;
inline int zeros(int x) { return ((x ^ (x - 1)) & x); }
void add(int pos, int val) {
  for (int i = pos; i <= n; i += zeros(i)) {
    t[i] += val;
  }
}
int getSum(int pos) {
  int sum = 0;
  for (int i = pos; i >= 1; i -= zeros(i)) {
    sum += t[i];
  }
  return sum;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    inde[x] = i;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 2 * i; j <= n; j += i) {
      pai[max(inde[i], inde[j])].push_back(min(inde[i], inde[j]));
    }
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    query[y - 1].push_back(make_pair(x - 1, i));
  }
  int result[m + 5];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < pai[i].size(); j++) {
      add(pai[i][j] + 1, 1);
    }
    for (int j = 0; j < query[i].size(); j++) {
      result[query[i][j].second] =
          getSum(i + 1) - getSum(query[i][j].first) + i + 1 - query[i][j].first;
    }
  }
  for (int i = 0; i < m; i++) {
    printf("%d\n", result[i]);
  }
  return 0;
}
