#include <bits/stdc++.h>
using namespace std;
const int mxn = 2e5 + 2;
int t, n, k, q, l, r, w;
int ans[mxn], cnt[mxn], ind[mxn];
vector<int> v, adj[mxn], jda[mxn], a;
bool b[mxn];
struct item {
  int r, l, i;
};
struct segtree {
  int size;
  vector<int> v;
  void init(int n) {
    size = 1;
    while (size < n) {
      size *= 2;
    }
    v.assign(2 * size, 0);
  }
  void opr(int i, int k, int x, int lx, int rx) {
    if (lx + 1 == rx) {
      v[x] += k;
      return;
    }
    int m = (lx + rx) / 2;
    if (i < m) {
      opr(i, k, 2 * x + 1, lx, m);
    } else {
      opr(i, k, 2 * x + 2, m, rx);
    }
    v[x] = v[2 * x + 1] + v[2 * x + 2];
  }
  void opr(int i, int k) { opr(i, k, 0, 0, size); }
  int calc(int l, int r, int x, int lx, int rx) {
    if (rx <= l || r <= lx) {
      return 0;
    }
    if (l <= lx && rx <= r) {
      return v[x];
    }
    int m = (lx + rx) / 2;
    int ans1 = calc(l, r, 2 * x + 1, lx, m);
    int ans2 = calc(l, r, 2 * x + 2, m, rx);
    return ans1 + ans2;
  }
  int calc(int l, int r) { return calc(l, r, 0, 0, size); }
};
vector<item> fq;
bool comp(item a, item b) {
  if (a.r < b.r) {
    return true;
  } else if (a.r > b.r) {
    return false;
  }
  if (a.l < b.l) {
    return true;
  } else if (a.l > b.l) {
    return false;
  }
  if (a.i < b.i) {
    return true;
  } else if (a.i > b.i) {
    return false;
  }
  return true;
}
void input() {
  v.clear();
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> w;
    ind[w] = i;
    v.push_back(w);
  }
  for (int i = 0; i < q; i++) {
    cin >> l >> r;
    l--;
    fq.push_back({r, l, i});
  }
}
void solve() {
  segtree st;
  st.init(n);
  for (int i = 1; i <= n / 2; i++) {
    for (int j = i + i; j <= n; j += i) {
      adj[j].push_back(i);
      jda[i].push_back(j);
    }
  }
  sort(fq.begin(), fq.end(), comp);
  for (int j = 0; j < fq[0].r; j++) {
    b[v[j]] = 1;
    for (int w = 0; w < adj[v[j]].size(); w++) {
      int x = adj[v[j]][w];
      if (b[x] == 0) {
        continue;
      } else {
        if (cnt[x] == 0) {
          a.push_back(x);
        }
        cnt[x]++;
      }
    }
    for (int w = 0; w < jda[v[j]].size(); w++) {
      int x = jda[v[j]][w];
      if (b[x] == 0) {
        continue;
      } else {
        if (cnt[x] == 0) {
          a.push_back(x);
        }
        cnt[x]++;
      }
    }
  }
  for (int i = 0; i < a.size(); i++) {
    st.opr(ind[a[i]], cnt[a[i]]);
    cnt[a[i]] = 0;
  }
  a.clear();
  ans[fq[0].i] = st.calc(fq[0].l, fq[0].r) + (fq[0].r - fq[0].l);
  for (int i = 1; i < q; i++) {
    for (int j = fq[i - 1].r; j < fq[i].r; j++) {
      b[v[j]] = 1;
      for (int w = 0; w < adj[v[j]].size(); w++) {
        int x = adj[v[j]][w];
        if (b[x] == 0) {
          continue;
        } else {
          if (cnt[x] == 0) {
            a.push_back(x);
          }
          cnt[x]++;
        }
      }
      for (int w = 0; w < jda[v[j]].size(); w++) {
        int x = jda[v[j]][w];
        if (b[x] == 0) {
          continue;
        } else {
          if (cnt[x] == 0) {
            a.push_back(x);
          }
          cnt[x]++;
        }
      }
    }
    for (int j = 0; j < a.size(); j++) {
      st.opr(ind[a[j]], cnt[a[j]]);
      cnt[a[j]] = 0;
    }
    a.clear();
    ans[fq[i].i] = st.calc(fq[i].l, fq[i].r) + (fq[i].r - fq[i].l);
  }
  for (int i = 0; i < q; i++) {
    cout << ans[i] << "\n";
  }
}
int main() {
  ios::sync_with_stdio(false);
  input(), solve();
  return 0;
}
