#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>

using namespace std;

#define int long long

int inf = 1000000000;

mt19937 rnd_(12);


vector <vector <int>> g;

int hs(int u , int v) {
    return u*inf+ v;
}

signed 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];

    for (int i = 0 ; i < q ; i++) {
        int t;
        cin >> t;

        if (t == 2) {
            int l ,  r;
            cin >> l >> r;
            l--;
            r--;
            
            int ans = r - l+1;
            if (l == r) {
                if (a[l] == -1) {
                    cout << 0 << "\n";
                }
                else {
                    cout << 1 << "\n";
                }
            }
            else {
                if (a[l] == -1)
                    ans--;


                if (a[r] == -1)
                    ans--;

                cout << ans << "\n";
            }

        }
    }

}
