#include using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); ll N, Q, A; cin >> N >> Q; vector> fac(1e5+1), v(1e5+1); for (int i=1; i<=1e5; i++){ for (int j=i; j<=1e5; j+=i){ fac[j].push_back(i); } } for (int i=1; i<=N; i++){ cin >> A; for (auto x : fac[A]){ v[x].push_back(i); } } while(Q--){ ll L, R, K; cin >> L >> R >> K; cout << upper_bound(v[K].begin(), v[K].end(), R)-lower_bound(v[K].begin(), v[K].end(), L) << endl; } return 0; }