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

int main() {
    #define ll long long

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout.tie(NULL);
    
    int n,q,type,p,l,r,sum,len;
    cin >> n >> q;
    int a[n];
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    bool t;

    int s1[n];
    s1[0] = a[0];
    for(int i = 1; i < n; i++)
    {
        s1[i] = s1[i-1] + a[i];
    }

    for(int Q = 0; Q < q; Q++)
    {
        cin >> type;
        if(type == 1)
        {
            cin >> p;
            a[p-1] = 0 - a[p-1];
        }
        else
        {
            cin >> l >> r;
            sum = s1[r-1] - (l == 1 ? 0 : s1[l-2]);
            len = r-l+1;

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

            cout << len << "\n";
        }
    }
}