#include <bits/stdc++.h>
using namespace std;
namespace Flandre_Scarlet {
struct node {
  int l, r, id;
} q[255555];
bool operator<(node a, node b) { return a.l > b.l; }
int n, m;
int a[255555];
void R1(int &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (c < '0' or c > '9') f = (c == '-') ? -1 : 1, c = getchar();
  while (c >= '0' and c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  x = (f == 1) ? x : -x;
}
void Input() {
  R1(n), R1(m);
  for (int i = 1; i <= n; ++i) R1(a[i]);
  for (int i = 1; i <= m; ++i) {
    int l, r;
    R1(l), R1(r);
    if (l > r) swap(l, r);
    q[i] = (node){l, r, i};
  }
}
int pos[255555];
int ans[255555];
vector<int> mul[255555];
void initmul() {
  for (int i = 1; i <= n; ++i) pos[a[i]] = i;
  for (int i = 1; i <= n; ++i) {
    for (int num = a[i]; num <= n; num += a[i]) {
      if (pos[num] >= i) {
        mul[i].push_back(pos[num]);
      } else {
        mul[pos[num]].push_back(i);
      }
    }
  }
}
class BIT {
 public:
  int tree[255555];
  int len;
  void BuildTree(int _len) {
    len = _len;
    memset(tree, 0, sizeof(tree));
  }
  void Add(int pos, int val = 1) {
    for (int i = pos; i <= len; i += (i & (-i))) {
      tree[i] += val;
    }
  }
  int Query(int pos) {
    int ans = 0;
    for (int i = pos; i > 0; i -= (i & (-i))) {
      ans += tree[i];
    }
    return ans;
  }
} T;
void Soviet() {
  initmul();
  sort(q + 1, q + m + 1);
  T.BuildTree(n);
  int Max = n + 1;
  for (int i = 1; i <= m; ++i) {
    for (int j = q[i].l; j <= Max - 1; ++j) {
      for (int k = 0; k <= (int)mul[j].size() - 1; ++k) {
        T.Add(mul[j][k], 1);
      }
    }
    ans[q[i].id] = T.Query(q[i].r);
    Max = q[i].l;
  }
  for (int i = 1; i <= m; ++i) printf("%d\n", ans[i]);
}
void IsMyWife() {
  Input();
  Soviet();
}
}  // namespace Flandre_Scarlet
int main() {
  Flandre_Scarlet::IsMyWife();
  getchar();
  getchar();
  return 0;
}
