#include <bits/stdc++.h>

#define ll long long

using namespace std;
ll n, q;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> q;
    vector<ll> g(n + 1);
    for(ll i = 1; i <= n;i++){
        cin >> g[i];
    }
     while(q--){
        ll typ;
        cin >> typ;
        if(typ == 1){
            
        }else{
            ll l, r;
            cin >> l >> r;
            ll ans = r - l + 1;
            if(g[l] == -1) ans--;
            if(g[r] == -1) ans--;
            cout << ans << endl;
        }
        
    }
    
}
