#include <bits/stdc++.h>
using namespace std;
int n, m, a[200005], pos[200005];
vector<int> Div[200005];
int Sum, ans[200005];
pair<pair<int, int>, int> que[200005];
struct BIT {
  int tree[200005];
  void Up(int x) {
    while (x < 200005) {
      tree[x]++;
      x += x & (-x);
    }
  }
  int Get(int x) {
    int r = 0;
    while (x) {
      r += tree[x];
      x -= x & (-x);
    }
    return r;
  }
};
BIT T;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  for (int i = 1; i < 200005; i++) {
    if (pos[i] == 0) continue;
    for (int j = i; j < 200005; j += i) {
      if (pos[j] == 0) continue;
      Div[max(pos[i], pos[j])].push_back(min(pos[i], pos[j]));
    }
  }
  for (int i = 1; i <= m; i++)
    cin >> que[i].first.second >> que[i].first.first, que[i].second = i;
  sort(que + 1, que + m + 1);
  int cur = 1;
  for (int i = 1; i <= m; i++) {
    while (cur <= que[i].first.first) {
      Sum += Div[cur].size();
      for (int j = 0; j < Div[cur].size(); j++) T.Up(Div[cur][j]);
      cur++;
    }
    ans[que[i].second] = Sum - T.Get(que[i].first.second - 1);
  }
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
}
