#include <bits/stdc++.h>
using namespace std;
class BIT {
  int n;
  vector<long long> data;

 public:
  BIT(int n) {
    this->n = n;
    data.assign(n + 1, 0);
  }
  void add(int k, long long x) {
    ++k;
    while (k <= n) {
      data[k] += x;
      k += k & -k;
    }
  }
  long long sum(int k) {
    ++k;
    long long ret = 0;
    while (k > 0) {
      ret += data[k];
      k -= k & -k;
    }
    return ret;
  }
  long long sum(int a, int b) { return sum(b) - sum(a - 1); }
};
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1);
  vector<int> index(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    index[a[i]] = i;
  }
  vector<pair<pair<int, int>, int> > q(m);
  for (int i = 0; i < m; ++i) {
    cin >> q[i].first.second >> q[i].first.first;
    q[i].second = i;
  }
  sort(q.begin(), q.end());
  BIT b(n + 1);
  int k = 0;
  vector<long long> ret(m);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j * j <= a[i]; ++j) {
      if (a[i] % j == 0) {
        if (index[j] < i) b.add(index[j], 1);
        if (j * j < a[i] && index[a[i] / j] < i) b.add(index[a[i] / j], 1);
      }
    }
    for (int j = a[i]; j <= n; j += a[i]) {
      if (index[j] <= i) b.add(index[j], 1);
    }
    while (k < m && q[k].first.first == i) {
      ret[q[k].second] = b.sum(q[k].first.second, q[k].first.first);
      ++k;
    }
  }
  for (int i = 0; i < m; ++i) cout << ret[i] << endl;
  return 0;
}
