#include <bits/stdc++.h>
using namespace std;
namespace Fread {
const int MAXN = 1 << 20;
char buf[MAXN], *S, *T;
inline char getchar() {
  if (S == T) {
    T = (S = buf) + fread(buf, 1, MAXN, stdin);
    if (S == T) return EOF;
  }
  return *S++;
}
}  // namespace Fread
inline int read() {
  int f = 1, x = 0;
  char ch = Fread::getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = Fread::getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = Fread::getchar();
  }
  return x * f;
}
inline long long readll() {
  long long f = 1, x = 0;
  char ch = Fread::getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = Fread::getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = Fread::getchar();
  }
  return x * f;
}
const int MAXN = 2e5;
int n, m, a[MAXN + 5], pos[MAXN + 5], cnt;
long long ans[MAXN + 5];
struct event {
  int type, l, r, id;
  bool operator<(const event &b) const {
    return l < b.l || (l == b.l && type < b.type);
  }
  event(int _type, int _l, int _r) {
    type = _type;
    l = _l;
    r = _r;
  }
  event() {}
} q[MAXN * 20];
struct FenwickTree {
  long long c[MAXN + 5];
  void modify(int p, long long v) {
    for (; p <= n; p += (p & (-p))) c[p] += v;
  }
  long long query(int p) {
    long long res = 0;
    for (; p; p -= (p & (-p))) res += c[p];
    return res;
  }
  FenwickTree() {}
} F;
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; ++i) a[i] = read(), pos[a[i]] = i;
  for (int i = 1; i <= m; ++i)
    q[i].l = read(), q[i].r = read(), q[i].type = 1, q[i].id = i;
  cnt = m;
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; j += i) {
      int l = pos[i], r = pos[j];
      if (l > r) swap(l, r);
      q[++cnt] = event(2, l, r);
      F.modify(r, 1);
    }
  }
  sort(q + 1, q + cnt + 1);
  for (int i = 1; i <= cnt; ++i) {
    if (q[i].type == 1) {
      ans[q[i].id] += F.query(q[i].r);
    } else {
      F.modify(q[i].r, -1);
    }
  }
  for (int i = 1; i <= m; ++i) printf("%lld\n", ans[i]);
  return 0;
}
