#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m;
struct node{
int s,e,m,val,lazy;
node *l,*r;
node(int _s, int _e):
s(_s),e(_e),m((_s+_e)/2),val(0){
if (s!=e){
l = new node(s,m);
r = new node(m+1,e);
}
}
void update(int p, int v){
if (s==e) {val = v; return;}
if (p>m) r->update(p,v);
else l->update(p,v);
val = max(l->val,r->val);
}
int query(int a, int b){
if (b<s or a>e) return 0;
if (a<=s and b>=e) {return val;}
return max(l->query(a,b),r->query(a,b));
}
};
signed main(){
cin>>n>>m;
vector<int> n1;
n1.resize(n);
vector<pair<pair<int,int> , pair<int,int> > >n2;
node *root = new node(0,n-1);
for (int i = 0;i<n;i++) cin>>n1[i];
for (int i = 0;i<m;i++){
bool hi = false;
int a,b,k;
cin>>a>>b>>k;
n2.push_back(make_pair(make_pair(b-1,a-1),make_pair(k,i)));
}
sort(n2.begin(),n2.end());
int r = -1;
int r1 = 0;
vector<int> ans;
ans.resize(m);
for (int i = 0;i<m;i++){
stack<pair<int,int> > s;
while (r!=n2[i].first.first){
r++;
while (!s.empty()and s.top().first<n1[r])s.pop();
if (!s.empty()){
root->update(s.top().second,s.top().first+n1[r]);
}
s.push(make_pair(n1[r],r));
}
if (root->query(n2[i].first.second,n2[i].first.first)>n2[i].second.first) ans[n2[i].second.second] = 0;
else ans[n2[i].second.second] = 1;
}
for (int i = 0;i<m;i++) cout<<ans[i]<<"\n";
return 0;
}