/* AUTHOR: TUAN ANH - BUI */
// ~~ icebear ~~
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
template<class X, class Y>
bool minimize(X &x, const Y &y) {
if (x > y) return x = y, true;
return false;
}
template<class X, class Y>
bool maximize(X &x, const Y &y) {
if (x < y) return x = y, true;
return false;
}
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for(int i=(a); i>=(b); --i)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define RED(i, n) for(int i=(n)-1; i>=0; --i)
#define MASK(i) (1LL << (i))
#define BIT(S, i) (((S) >> (i)) & 1)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define task "icebear"
/*END OF TEMPLATE. ICEBEAR AND THE CAT WILL WIN TST26 */
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 27092008;
const ll INF = (ll)1e18 + 27092008;
const int N = 5e5 + 5;
int n, q;
ll pos[N], dist_per_move[N], time_per_move[N], require_dist[N];
int f(int t, int r) {
int low = 0, high = n, res = 0;
while(low <= high) {
int mid = (low + high) >> 1;
if (pos[mid] + (t / time_per_move[mid]) * dist_per_move[mid] > r) res = mid + 1, low = mid + 1;
else high = mid - 1;
}
return n - res + 1;
}
void init(void) {
cin >> n >> q;
FOR(i, 1, n) cin >> require_dist[i];
FOR(i, 0, n) pos[i] = -i;
dist_per_move[0] = time_per_move[0] = 1;
}
void process(void) {
FOR(i, 1, n) {
ll move_require = (require_dist[i] + dist_per_move[i - 1] - 1) / dist_per_move[i - 1];
time_per_move[i] = move_require * time_per_move[i - 1];
dist_per_move[i] = pos[i - 1] + move_require * dist_per_move[i - 1] - 1 - pos[i];
}
while(q--) {
int t, l, r;
cin >> t >> l >> r;
cout << f(t, r) - f(t, l - 1) << '\n';
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int tc = 1;
// cin >> tc;
while(tc--) {
init();
process();
}
return 0;
}