#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
using ll = long long;



struct DSU {
    int n;
    vector<int> p, h;

    DSU(int m) {
        n = m;
        p.assign(n + 1, -1);
        h.assign(n + 1, 1);

        for (int i = 0; i <= n; i++) {
            p[i] = i;
            h[i] = 1;
        }
    }

    int findParent(int node) {
        if (p[node] == node) {
            return node;
        }
        return p[node] = findParent(p[node]);
    }

    bool sameSet(int a, int b) {
        a = findParent(a);
        b = findParent(b);
        return a == b;
    }

    void unionSets(int a, int b) {
        a = findParent(a);
        b = findParent(b);
        if (a == b) return;
        if (h[a] < h[b]) {
            swap(a, b);
        }
        p[b] = a;
        h[a] += h[b];
    }
};

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

    int n, q;
    cin >> n >> q;

    int a[n + 1] = {};
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    int deleted[n + 1] = {};
    int cur = 1;

    while (q--) {
        int type;
        cin >> type;

        if (type == 1) {
            int i;
            cin >> i;
            a[i] = -a[i];
        }
        else {
            int l, r;
            cin >> l >> r;

            int ans = r - l + 1;
            
            int sum = 0;
            for (int i = l; i <= r; i++) {
                sum += a[i];
                if (sum < 0) {
                    deleted[i] = cur;
                    ans--;
                    sum = 0;
                }
            }
            

            sum = 0;
            for (int i = r; i >= l; i--) {
                if (deleted[i] != cur) {
                    sum += a[i];
                    if (sum < 0) {
                        deleted[i] = cur;
                        ans--;
                        sum = 0;
                    }
                }
            }

            printf("%i\n", ans);
        }

        cur++;
    }

    
}