#pragma GCC optimize("O3,inline")
#include <bits/stdc++.h>
using namespace std;
struct node1 {
int s, e, m, v, lazy;
node1* l, * r;
node1(int _s, int _e) : s(_s), e(_e), m((_s + _e) / 2), v(0), lazy(0) {
if (s != e)
l = new node1(s, m),
r = new node1(m + 1, e);
}
void prop() {
if (s == e || lazy == 0) return;
l->v += lazy;
r->v += lazy;
l->lazy += lazy;
r->lazy += lazy;
lazy = 0;
}
void upd(int a, int b, int x) {
if (b < s || a > e) return;
if (a <= s && b >= e) {
v += x;
lazy += x;
return;
}
prop();
l->upd(a, b, x);
r->upd(a, b, x);
v = max(l->v, r->v);
}
int qry(int a, int b) {
if (b < s || a > e) return 0;
if (a <= s && b >= e) return v;
prop();
return max(l->qry(a, b), r->qry(a, b));
}
} *root1;
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int N, M, a, b, c; cin >> N >> M;
vector<int> W, died(M, 0);
for (int i = 0; i < N; i++) {
cin >> a;
W.push_back(a);
}
root1 = new node1(0, N - 1);
vector<pair<pair<int, int>, pair<int, int>>> quers;
for (int i = 0; i < M; i++) {
cin >> a >> b >> c; a--, b--;
quers.push_back({ {a, b}, {c, i} });
}
sort(quers.begin(), quers.end(), greater<pair<pair<int, int>, pair<int, int>>>());
int crnti = N;
stack<pair<int, int>> stk;
stk.push({ INT_MAX, N });
for (int i = 0; i < M; i++) {
while (crnti > quers[i].first.first) {
crnti--;
while (stk.size() && stk.top().first < W[crnti]) {
auto j = stk.top(); stk.pop();
root1->upd(j.second, j.second, W[crnti] + j.first);
root1->upd(j.second + 1, stk.top().second - 1, W[crnti] - j.first);
}
stk.push({ W[crnti], crnti });
}
if (root1->qry(quers[i].first.first, quers[i].first.second) <= quers[i].second.first) died[quers[i].second.second] = 1;
}
for (int i : died) cout << i << '\n';
}