#include <bits/stdc++.h>
using namespace std;
int N, M;
int A[200002], X[200002], Y[200002], pos[200002];
long long result[200002];
vector<int> V[200002];
int is[200002];
long long AIB[200002];
inline bool compare(const int& i1, const int& i2) { return X[i1] < X[i2]; }
void update(int pos, int val) {
  for (; pos <= 200000; pos += pos & -pos) AIB[pos] += val;
}
long long query(int pos) {
  long long sum = 0;
  for (; pos >= 1; pos -= pos & -pos) sum += AIB[pos];
  return sum;
}
int main() {
  cin >> N >> M;
  for (int i = 1; i <= N; ++i) {
    cin >> A[i];
    is[A[i]] = i;
  }
  for (int i = 1; i <= M; ++i) {
    cin >> X[i] >> Y[i];
    pos[i] = i;
  }
  sort(pos + 1, pos + M + 1, compare);
  for (int i = 1; i <= N; ++i) {
    for (int j = 2 * A[i]; j <= N; j += A[i]) {
      if (is[j] < i) {
        V[is[j]].push_back(i);
        update(i, 1);
      } else {
        V[i].push_back(is[j]);
        update(is[j], 1);
      }
    }
  }
  int now = 1;
  for (int i = 1; i <= N; ++i) {
    while (now <= M && X[pos[now]] == i) {
      result[pos[now]] = query(Y[pos[now]]) + (Y[pos[now]] - X[pos[now]] + 1);
      ++now;
    }
    for (vector<int>::iterator it = V[i].begin(); it != V[i].end(); ++it)
      update(*it, -1);
  }
  for (int i = 1; i <= M; ++i) cout << result[i] << '\n';
}
