#include using namespace std; #include using namespace atcoder; using mint=modint998244353; //1000000007; using ll=long long; using pp=pair; #define sr string #define vc vector #define fi first #define se second #define rep(i,n) for(int i=0;i<(int)n;i++) #define pb push_back #define all(v) v.begin(),v.end() #define pque priority_queue #define bpc(a) __builtin_popcount(a) int main(){ int n,q;cin>>n>>q; int m=1e5+1; vc v(m,vc(0)); rep(i,n){ int a;cin>>a; for(int j=1;j*j<=a;j++)if(a%j==0){ v[j].pb(i); if(j!=a/j)v[a/j].pb(i); } } rep(i,q){ int l,r,x;cin>>l>>r>>x; l--; int ans=lower_bound(all(v[x]),r)-lower_bound(all(v[x]),l); cout<