#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define all(x) x.begin(), x.end()
#define fastread ios_base::sync_with_stdio(0);cin.tie(NULL)
#define sum(x) accumulate(all(x),0LL)
#define what_is(x) cerr << #x << " = " << (x) << '\n'
#define pb push_back

int main()
{
    fastread;
    int n,q;
    cin >> n >> q;
    vii v(n);
    for(int i=0;i<n;i++)
        cin >> v[i];
    while (q--) {
        int x,l,r;
        cin >> x >> l >> r;
        l--;
        r--;
        if (v[l] == -1) {
            if (v[r] == -1) {
                cout << r - l << "\n";
            }
            else {
                cout << r - l + 1 << "\n";
            }
        }
        else {
            if (v[r] == -1) {
                cout << r - l + 1 << "\n";
            }
            else {
                cout << r - l + 1 << "\n";
            }
        }
    }
    return 0;
}