#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
vector<long long> v[N], g[N];
long long a[N], p[N], ans[N];
long long n, Q, l[N], r[N], tree[N];
inline void add(long long x, long long v) {
  for (; x <= n; x += x & -x) tree[x] += v;
}
inline long long check(long long x) {
  long long cnt = 0;
  for (; x; x -= x & -x) cnt += tree[x];
  return cnt;
}
signed main() {
  scanf("%d%d", &n, &Q);
  for (long long i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    p[a[i]] = i;
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = i; j <= n; j += i) {
      v[min(p[i], p[j])].push_back(max(p[i], p[j]));
    }
  }
  for (long long i = 1; i <= Q; i++) {
    scanf("%d%d", &l[i], &r[i]);
    g[l[i]].push_back(i);
  }
  for (long long i = n; i >= 0; i--) {
    for (long long j = 0; j < v[i].size(); j++) add(v[i][j], 1);
    for (long long j = 0; j < g[i].size(); j++) {
      ans[g[i][j]] = check(r[g[i][j]]);
    }
  }
  for (long long i = 1; i <= Q; i++) {
    printf("%d\n", ans[i]);
  }
}
