#include <bits/stdc++.h>
using namespace std;
const int maxn = ((int)2e5) + 5;
const int smaxn = 4 * maxn;
using namespace std;
int arr[maxn], posOf[maxn];
vector<pair<int, int>> divPairs, query, combined;
long long int ans[maxn];
long long int tree[maxn];
int read(int idx) {
  int sum = 0;
  while (idx > 0) {
    sum += tree[idx];
    idx -= (idx & -idx);
  }
  return sum;
}
void update(int idx, int val) {
  while (idx < maxn) {
    tree[idx] += val;
    idx += (idx & -idx);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    posOf[arr[i]] = i + 1;
  }
  for (int i = 0; i < n; i++) {
    int div = arr[i];
    while (div <= n) {
      if ((div) % arr[i] == 0) {
        divPairs.push_back(make_pair(min(posOf[arr[i]], posOf[div]),
                                     max(posOf[arr[i]], posOf[div])));
        combined.push_back(
            make_pair(min(posOf[arr[i]], posOf[div]), divPairs.size()));
      }
      div += arr[i];
    }
  }
  for (int i = 0; i < m; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    query.push_back(make_pair(l, r));
    combined.push_back(make_pair(l, -(i + 1)));
  }
  sort(combined.begin(), combined.end());
  reverse(combined.begin(), combined.end());
  for (int i = 0; i < combined.size(); i++) {
    int type = combined[i].second;
    if (type < 0) {
      int l = combined[i].first;
      int r = query[-type - 1].second;
      ans[-type - 1] = read(r) - read(l - 1);
    } else {
      int r = divPairs[type - 1].second;
      update(r, 1);
    }
  }
  for (int i = 0; i < m; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
