#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;
            if (left % 2 == 0) ans--;
            if (right % 2 == 0) ans--;
            cout << ans << "\n";
        }
    }
}