#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& _p) {
  return os << "(" << _p.first << "," << _p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& _V) {
  bool f = true;
  os << "[";
  for (auto v : _V) {
    os << (f ? "" : ",") << v;
    f = false;
  }
  return os << "]";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& _S) {
  bool f = true;
  os << "(";
  for (auto s : _S) {
    os << (f ? "" : ",") << s;
    f = false;
  }
  return os << ")";
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& _M) {
  return os << set<pair<T, U>>(_M.begin(), _M.end());
}
const signed long long INF = 1000000100;
const long double EPS = 1e-9;
struct Fenwick {
  int *A, M;
  Fenwick(int n) {
    M = 1 << (32 - __builtin_clz(n));
    A = new int[M];
    for (int(i) = (0); (i) < (M); (i)++) A[i] = 0;
  }
  int query(int k) {
    int r = 0;
    for (; k > 0; k -= (k & -k)) r += A[k];
    return r;
  }
  int query(int a, int b) {
    if (b == 0)
      return query(a);
    else
      return query(b) - query(a - 1);
  }
  void insert(int k, int v) {
    for (; k < M; k += (k & -k)) A[k] += v;
  }
  ~Fenwick() { delete[] A; }
};
const int MAXN = 200100;
int N, Q;
int A[MAXN];
int Z[MAXN];
int R[MAXN];
vector<int> W[MAXN];
vector<tuple<int, int, int>> queries;
Fenwick F(MAXN);
void read_data() {
  scanf("%d %d", &N, &Q);
  for (int(i) = (1); (i) <= (N); (i)++) scanf("%d", A + i);
  for (int(i) = (1); (i) <= (Q); (i)++) {
    int a, b;
    scanf("%d %d", &a, &b);
    queries.emplace_back(b, a, i);
  }
}
void pre() {
  for (int(i) = (1); (i) <= (N); (i)++) Z[A[i]] = i;
  for (int(i) = (1); (i) <= (N); (i)++)
    for (int(j) = (1); (j) <= (INF); (j)++) {
      int t = A[i] * j;
      if (t >= MAXN) break;
      int k = Z[t];
      if (k == 0) continue;
      W[max(k, i)].push_back(min(k, i));
    }
}
void solve() {
  pre();
  sort(queries.begin(), queries.end());
  int right = 0;
  for (auto q : queries) {
    int a, b, id;
    tie(b, a, id) = q;
    while (right < b) {
      ++right;
      for (int left : W[right]) F.insert(left, 1);
    }
    R[id] = F.query(a, b);
  }
  for (int(i) = (1); (i) <= (Q); (i)++) printf("%d\n", R[i]);
}
int main() {
  read_data();
  solve();
}
