#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
long long mod = 1000000007;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
bool is_vowel(char c) {
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') return 1;
  return 0;
}
double getDistance(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
long long extended_euclidean(long long a, long long b, long long &x,
                             long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long g = extended_euclidean(b, a % b, y, x);
  y -= (a / b) * x;
  return g;
}
long long power(long long base, long long p) {
  if (p == 1) return base;
  if (!p) return 1ll;
  long long ret = power(base, p / 2);
  ret *= ret;
  ret %= mod;
  if (p & 1) ret *= base;
  return ret % mod;
}
vector<int> v[N];
int arr[N], pos[N];
int bit[N], n;
void update(int idx, int val) {
  while (idx <= n) {
    bit[idx] += val;
    idx += idx & -idx;
  }
}
int get(int idx) {
  int ret = 0;
  while (idx > 0) {
    ret += bit[idx];
    idx -= idx & -idx;
  }
  return ret;
}
int sol[N];
vector<pair<int, int> > query[N];
int main() {
  int q;
  scanf("%d %d", &n, &q);
  for (int i = (1); i <= (n); ++i) scanf("%d", &arr[i]), pos[arr[i]] = i;
  for (int i = (1); i <= (n); ++i)
    for (int j = i; j <= n; j += i)
      v[min(pos[i], pos[j])].push_back(max(pos[i], pos[j])),
          update(max(pos[i], pos[j]), 1);
  for (int i = (1); i <= (q); ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    query[a].push_back(pair<int, int>(b, i));
  }
  for (int i = (1); i <= (n); ++i) {
    for (int j = (0); j <= ((int)query[i].size() - 1); ++j) {
      sol[query[i][j].second] = get(query[i][j].first);
    }
    for (int j = (0); j <= ((int)v[i].size() - 1); ++j) update(v[i][j], -1);
  }
  for (int i = (1); i <= (q); ++i) printf("%d\n", sol[i]);
  return 0;
}
