#include <bits/stdc++.h>
using namespace std;
int a[200005], poz[200005], aib[200005], aib1[200005], n;
long long sol[200005];
vector<int> Mic[200005], Mare[200005];
struct query {
  int val, poz;
};
vector<query> Left[200005], Right[200005];
inline void Ciur() {
  int i, j;
  for (i = 1; i <= n; ++i)
    for (j = i; j <= n; j += i)
      if (poz[i] < poz[j])
        Mic[poz[j]].push_back(poz[i]);
      else
        Mare[poz[j]].push_back(poz[i]);
}
inline void Update(int p) {
  int i;
  for (i = p; i > 0; i -= (i & (-i))) ++aib[i];
}
inline void Update1(int p) {
  int i;
  for (i = p; i <= n; i += (i & (-i))) ++aib1[i];
}
inline int Query(int p) {
  int i, sol = 0;
  for (i = p; i <= n; i += (i & (-i))) sol += aib[i];
  return sol;
}
inline int Query1(int p) {
  int i, sol = 0;
  for (i = p; i > 0; i -= (i & (-i))) sol += aib1[i];
  return sol;
}
int main() {
  int i, m, x, y;
  query w;
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (i = 1; i <= n; ++i) {
    cin >> a[i];
    poz[a[i]] = i;
  }
  Ciur();
  for (i = 1; i <= m; ++i) {
    cin >> x >> y;
    w.val = x;
    w.poz = i;
    Right[y].push_back(w);
    w.val = y;
    w.poz = i;
    Left[x].push_back(w);
  }
  for (i = 1; i <= n; ++i) {
    vector<int>::iterator it;
    vector<query>::iterator itt;
    for (it = Mic[i].begin(); it != Mic[i].end(); ++it) Update(*it);
    for (itt = Right[i].begin(); itt != Right[i].end(); ++itt)
      sol[itt->poz] += Query(itt->val);
  }
  for (i = n; i; --i) {
    vector<int>::iterator it;
    vector<query>::iterator itt;
    for (it = Mare[i].begin(); it != Mare[i].end(); ++it) Update1(*it);
    for (itt = Left[i].begin(); itt != Left[i].end(); ++itt)
      sol[itt->poz] += Query1(itt->val);
  }
  for (i = 1; i <= m; ++i) cout << sol[i] << "\n";
  return 0;
}
