#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int INF = (1 << 30) - 1;
const int MAXN = 400010;
const int mod = 1e9 + 7;
int n, m;
int pos[MAXN], A[MAXN];
vector<int> L[MAXN];
vector<int> R[MAXN];
long long ans[MAXN];
int C[MAXN];
int Q[MAXN][2];
void Update(int x, int d) {
  while (x <= n) {
    C[x] += d;
    x += x & (-x);
  }
}
int Getsum(int x) {
  int res = 0;
  while (x) {
    res += C[x];
    x -= x & (-x);
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &A[i]);
    pos[A[i]] = i;
  }
  for (int i = 1; i <= m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    Q[i][0] = a;
    Q[i][1] = b;
    L[a].push_back(i);
    R[b].push_back(i);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < L[i].size(); ++j) {
      int id = L[i][j];
      int tR = Q[id][1];
      ans[id] -= Getsum(tR) - Getsum(i - 1);
    }
    for (int j = 1; j * A[i] <= n; ++j) {
      Update(pos[j * A[i]], 1);
    }
    for (int j = 0; j < R[i].size(); ++j) {
      int id = R[i][j];
      int tL = Q[id][0];
      ans[id] += Getsum(i) - Getsum(tL - 1);
    }
  }
  for (int i = 1; i <= m; ++i) {
    printf("%I64d\n", ans[i]);
  }
  return 0;
}
