#include <bits/stdc++.h>
using namespace std;
vector<int> Right[201000];
vector<pair<int, int> > Q[201000];
int tree[201000];
int N, M;
int lowbit(int x) { return x & (-x); }
void insert(int pos, int val) {
  for (int x = pos; x <= N; x += lowbit(x)) tree[x] += val;
}
int getsum(int pos) {
  int res = 0;
  for (int x = pos; x > 0; x -= lowbit(x)) res += tree[x];
  return res;
}
int pos[201000], A[201000];
int ans[201000];
int main() {
  int i, j, a, b;
  while (scanf("%d%d", &N, &M) != EOF) {
    for (i = 0; i < N; i++)
      scanf("%d", &A[i + 1]), pos[A[i + 1]] = i + 1, Right[i + 1].clear(),
                                        Q[i + 1].clear();
    for (i = 1; i <= N; i++)
      for (j = i; j <= N; j += i) {
        int L = pos[i], R = pos[j];
        if (L > R) swap(L, R);
        Right[L].push_back(R);
      }
    for (i = 0; i < M; i++) {
      scanf("%d%d", &a, &b);
      Q[a].push_back(pair<int, int>(b, i));
    }
    for (i = 0; i < N + 10; i++) tree[i] = 0;
    for (i = N; i > 0; i--) {
      for (j = 0; j < Right[i].size(); j++) insert(Right[i][j], 1);
      for (j = 0; j < Q[i].size(); j++)
        ans[Q[i][j].second] = getsum(Q[i][j].first);
    }
    for (i = 0; i < M; i++) printf("%d\n", ans[i]);
  }
}
