#include <bits/stdc++.h>   struct event {     int t, time, L, R, idx;     event() {}     event(int t, int time, int L, int R, int idx)         : t(t), time(time), L(L), R(R), idx(idx) {}     bool operator<(const event& a) const {       return (time < a.time || (time == a.time && t < a.t));     }   } e[200005 * 23];   int n, m, i, j, ai, place[200005], L, R, en, idx, ans[200005], fw[200005];   void modify(int j) {     for (; j <= n; j = (j | (j - 1)) + 1) ++fw[j];   }   int query(int j) {     int rt = 0;     for (; j; j &= (j - 1)) rt += fw[j];     return rt;   }   int main(int argc, char* const argv[]) {     scanf( %d%d , &n, &m);     for (i = 1; i <= n; i++) {       scanf( %d , &ai);       place[ai] = i;     }     for (i = 1; i <= m; i++) {       scanf( %d%d , &L, &R);       e[++en] = event(2, R, L, R, i);       e[++en] = event(2, L - 1, L, R, -i);     }     for (i = 1; i <= n; i++) {       j = i;       while (j <= n) {         e[++en] = event(1, place[i], place[j], 0, 0);         j += i;       }     }     std::sort(e + 1, e + en + 1);     for (i = 1; i <= en; i++)       if (e[i].t == 1)         modify(e[i].L);       else {         idx = abs(e[i].idx);         ans[idx] += (query(e[i].R) - query(e[i].L - 1)) * (e[i].idx / idx);       }     for (i = 1; i <= m; i++) printf( %d n , ans[i]);     return 0;   }   