#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Unroll-loops")
#pragma GCC target("avx,avx2,tune=native")
using namespace std;

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

    int n, q;
    cin >> n >> q;
    int a[n+1], b[n+1];
    for (int i = 1; i <= n; i++) cin >> a[i];

    int type, pos, left, right;
    int ans, sum;
    for (int qi = 0; qi < q; qi++) {
        cin >> type;
        if (type == 1) {
            cin >> pos;
            a[pos] *= -1;
        } else {
            cin >> left >> right;
            ans = right - left + 1;
            for (int i = left; i <= right; i++) {
                b[i] = a[i];
            }
            sum = 0;
            for (int i = left; i <= right; i++) {
                sum += b[i];
                if (sum < 0) {
                    b[i] = 0;
                    sum++;
                    ans--;
                }
            }
            sum = 0;
            for (int i = right; i >= left; i--) {
                sum += b[i];
                if (sum < 0) {
                    b[i] = 0;
                    sum++;
                    ans--;
                }
            }
            cout << ans << "\n";
        }
    }
}
