#include <bits/stdc++.h>
using namespace std;
vector<int> divisor[200035];
int cc = 0;
vector<int> con[2500006];
int pos[2500006];
void div() {
  int n = 200005;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j = j + i) {
      divisor[j].push_back(i);
      int aa = pos[j];
      int bb = pos[i];
      if (aa > bb) swap(aa, bb);
      con[aa].push_back(bb);
    }
  }
}
bool compare(pair<int, pair<int, int>> a, pair<int, pair<int, int>> b) {
  return a.first > b.first;
}
int tree[2500006 * 3];
int query(int node, int b, int e, int ll, int rr) {
  if (rr < b || ll > e) return 0;
  if (ll <= b && e <= rr) return tree[node];
  int left = node * 2;
  int right = left + 1;
  int mid = (b + e) / 2;
  int p1 = query(left, b, mid, ll, rr);
  int p2 = query(right, mid + 1, e, ll, rr);
  return p1 + p2;
}
void update(int node, int b, int e, int pos) {
  if (pos < b || e < pos) return;
  if (b == pos && e == pos) {
    tree[node]++;
    return;
  }
  int left = node * 2;
  int right = left + 1;
  int mid = (b + e) / 2;
  update(left, b, mid, pos);
  update(right, mid + 1, e, pos);
  tree[node] = tree[left] + tree[right];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  scanf("%d%d", &n, &m);
  int a[n + 5];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    pos[a[i]] = i;
  }
  div();
  vector<pair<int, pair<int, int>>> query1;
  for (int i = 0; i < m; i++) {
    int aa, bb;
    scanf("%d%d", &aa, &bb);
    query1.push_back(make_pair(aa, make_pair(bb, i)));
  }
  sort(query1.begin(), query1.end(), compare);
  int range = n;
  int anslist[m + 5];
  for (int i = 0; i < query1.size(); i++) {
    int x = query1[i].first;
    int y = query1[i].second.first;
    int id = query1[i].second.second;
    for (int j = x; j <= range; j++) {
      for (int k = 0; k < con[j].size(); k++) {
        int now = con[j][k];
        update(1, 1, n, now);
      }
    }
    int ans = query(1, 1, n, x, y);
    anslist[id] = ans;
    range = x - 1;
  }
  for (int i = 0; i < m; i++) {
    printf("%d\n", anslist[i]);
  }
}
