#include <bits/stdc++.h>
#define int long long
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n,q;
std::cin >> n >> q;
std::vector<int> slow={0};
for(int i=0;i<n;i++){
int in;
std::cin >> in;
in=slow.back()*(in/(slow.back()+1));
slow.push_back(in);
}
while(q--){
int time,tl,tr;
std::cin >> time >> tl >> tr;
int l=0,r=slow.size();
while(l<r){
int mid=(l+r)/2;
if(slow[mid]*(time/slow[mid])-mid<=tr)r=mid;
else l=mid+1;
}
tr=r;
l=-1,r=slow.size()-1;
while(l<r){
int mid=(l+r+1)/2;
if(slow[mid]*(time/slow[mid])-mid>=tl)l=mid;
else r=mid-1;
}
tl=l;
std::cout << tl-tr+1;
}
}