#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define el '\n'
#define ff first
#define ss second
#define pii pair <ll, ll>
#define pb push_back
#define popb pop_back
#define fr(x, l, r) for(ll (x) = l; (x) <= r; (x)++)
#define frb(x, r, l) for(ll (x) = r; (x) >= l; (x)--)

mt19937_64 rnd(time(0));

ll const N = 110;
ll const INF = 1e18 + 100;

void chmax(ll &a, ll b) {
    a = max(a, b);
}

ll n, q;
ll a[N];

void solve() {
    cin >> n >> q;
    fr(i, 1, n)
        cin >> a[i];

    while(q--) {
        ll type;
        cin >> type;
        if(type == 1) {
            ll pos;
            cin >> pos;
            a[pos] *= -1;
        }
        else {
            ll l, r;
            cin >> l >> r;
            ll d = r - l + 1;
            if(d % 2 == 0) d--;
            else if(a[l] == -1) d -= 2;
            cout << d << el;
        }
    }
}   

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

    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}