#include<iostream>#include<algorithm>
using namespace std;int h[100010],n,m;#define lowb(x) ((x)&(-x))intque(int x){int ret =0;for(; x >=1; x -=lowb(x))ret += h[x];return ret;}voidupd(int x,int y){for(; x <= n; x +=lowb(x))h[x]+= y;}struct nod {int x, y, tp, id;
bool operator <(const nod &a)const{return x < a.x || x == a.x&&y < a.y || x == a.x&&y == a.y && tp ==0;}}e[5000010];int ans[100010],a[100010],pos[100010];intmain(){
cin >> n >> m;for(int i =1; i <= n; i++){
cin >> a[i]; pos[a[i]]= i;}int tot =0;for(int i =1; i <= n; i++){for(int j =2; i*j <= n; j++){
e[++tot]={ pos[i],pos[i*j],0};}}for(int i =1; i <= m; i++){int l, r; cin >> l >> r;
e[++tot]={ l -1,l -1,1,i };
e[++tot]={ l -1,r,-1,i };
e[++tot]={ r,l -1,-1,i };
e[++tot]={ r,r,1,i };}sort(e +1, e + tot +1);for(int i =1; i <= tot; i++){if(e[i].tp ==0){upd(e[i].y,1);}else{int tmp =que(e[i].y);
ans[e[i].id]+= e[i].tp*tmp;}}for(int i =1; i <= m; i++)cout << ans[i]<< endl;}