#include <bits/stdc++.h>
using namespace std;
mt19937 Rand(time(0));
const int maxn = 2e5 + 5;
const long long maxc = 1e9 + 7;
int p[maxn], r[maxn], n, m;
vector<int> in[maxn];
vector<int> query[maxn];
int bit[maxn], ans[maxn];
void up(int x) {
  for (; x <= n; x += x & -x) bit[x]++;
}
int get(int x) {
  int res = 0;
  for (; x > 0; x -= x & -x) res += bit[x];
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    p[x] = i;
  }
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j += i)
      in[min(p[i], p[j])].push_back(max(p[i], p[j]));
  for (int i = 1; i <= m; i++) {
    int l;
    cin >> l >> r[i];
    query[l].push_back(i);
  }
  for (int i = n; i >= 1; i--) {
    for (auto p : in[i]) up(p);
    for (auto x : query[i]) ans[x] = get(r[x]);
  }
  for (int i = 1; i <= m; i++) cout << ans[i] << "\n";
  return 0;
}
