/*IN FISH AT EGOI I TRUST*/
/*IN FISH AT EGOI I TRUST*/
/*IN FISH AT EGOI I TRUST*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppl;
typedef long double ld;

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
/*#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt")*/

ll n,q,a[100009],e[25][25];
bool isbit(ll a,int b){
   return (1&(a>>b));
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>q;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int L=1;L<=n;L++) for(int R=L;R<=n;R++) {
            e[L][R]=0;
            for(int mask=0;mask<=(1<<(R-L+1));mask++){
                 vector<ll> A;
                 for(int j=0;j<=R-L;j++) if(isbit(mask,j)) A.push_back(a[L+j]);
                 bool f=0; ll S=0;
                 for(auto x:A) {
                    S+=x;
                    if(S<0) f=1;
                 }
                 reverse(A.begin(),A.end());
                  S=0;
                 for(auto x:A) {
                    S+=x;
                    if(S<0) f=1;
                 }
                 ll o=A.size();
                 if(!f) e[L][R]=max(e[L][R],o);
             }
    }
    while(q--){
        ll c,L,R;
        cin>>c>>L>>R;
        cout<<e[L][R]<<"\n";
    }

    return 0;
}
