// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define all(a) (a).begin(), (a).end()

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> dp(1 << n);
    for (int mask = 0; mask < (1 << n); mask++) {
        bool res = 1;
        int s = 0, mx = 0;
        for (int i = 0; i < n;i++) {
            if (!((mask >> i) & 1)) continue;
            s += a[i];
            res &= s > -1;
            mx = max(s, mx);
        }
        if (s - mx < 0) res = 0;
        if (res) dp[mask] = __builtin_popcount(mask);
    }
    for (int m = 0; m < (1 << n); m++) {
        for (int i = 0; i < n;i++) {
            if (((m >> i) & 1)) continue;
            dp[m | (1 << i)] = max(dp[m | (1 << i)], dp[m]);
        }
    }
    while (q--) {
        int t, l, r;
        cin >> t >> l >> r;
        l--, r--;
        int m = (1 << (r + 1)) - (1 << l);
        cout << dp[m] << '\n';
    }
}