#include using namespace std; #define ll long long #define forin(in ,n) for(ll i=0; i>in[i] #define forout(out) for(ll i=0; i<(ll)out.size(); i++) cout<= n; --i) #define P pair #define all(v) v.begin(), v.end() #define fi first #define se second #define vvvll vector>> #define vvll vector> #define vll vector #define pqll priority_queue #define pqllg priority_queue, greater> constexpr ll INF = (1ll << 60); constexpr ll mod = 1000000007; //constexpr ll mod = 998244353; constexpr double pi = 3.14159265358979323846; template inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template void pt(T val) { cout << val << "\n"; } template void pt_vll(vector &v) { ll vs = v.size(); rep(i, vs) { cout << v[i]; if (i == vs - 1) cout << "\n"; else cout << " "; } } ll mypow(ll a, ll n) { ll ret = 1; if(n==0) return 1; if(a==0) return 0; rep(i, n) { if (ret > (ll)(1e18 + 10) / a) return -1; ret *= a; } return ret; } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } ll digsum(ll n) { ll res = 0; while(n > 0) { res += n%10; n /= 10; } return res; } vector enum_div(ll n){ //約数全列挙 vector ret; for(ll i = 1 ; i*i <= n ; ++i){ if(n%i == 0){ ret.push_back(i); if(i*i != n){ ret.push_back(n/i); } } } return ret; } int main() { ll n,m,q,x,l,r,k,ans=1; cin>>n;cin>>q; vector a(n); vll p; vvll st(100001); rep(i,n){ cin>>x; a[i]=x; } rep(i,n){ p=enum_div(a[i]); for(auto e:p){ st[e].push_back(i); } } rep(i,q){ cin>>l>>r>>x; k=upper_bound(all(st[x]),r-1)-lower_bound(all(st[x]),l-1); cout<