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

int main() {
    int n, q;
    cin >> n >> q;

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

    for (int w = 0; w < q; w++) {
        int input;
        cin >> input;

        if (input == 1) {
            int p;
            cin >> p;
            a[p] *= -1;
            continue;
        }

        int l, r;
        cin >> l >> r;
        
        int sum = 0;
        for (int i = l; i <= r; i++) {
            sum += a[i];
        }

        if (sum > 0) {
            cout << r - l + 1; 
        }
        else {
            cout << sum - l + 1;
        }
    }
}
