#include <bits/stdc++.h>

#ifndef LOCAL
#pragma GCC optimize("O3")
#endif

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;

const int mod = 1e9 + 7;

struct mint
{
    int x;

    mint(int x = 0) : x(x) {}

    friend mint operator+(mint a, mint b)
    {
        int res = a.x + b.x;
        return res - (res >= mod ? mod : 0);
    }

    friend mint operator-(mint a, mint b)
    {
        int res = a.x - b.x;
        return res + (res < 0 ? mod : 0);
    }

    friend mint operator*(mint a, mint b)
    {
        return ll(a.x) * b.x % mod;
    }
};

mint mpow(mint a, ll b)
{
    mint res = 1;
    while (b)
    {
        if (b & 1)
        {
            res = res * a;
        }
        a = a * a;
        b >>= 1;
    }
    return res;
}

void solve()
{
    int n, q;
    cin >> n >> q;
    vector<int> pr(n + 1);
    for (int i = 0; i < n; ++i)
    {
        cin >> pr[i + 1];
        pr[i + 1] += pr[i] - 1;
    }
    for (int i = 0; i < q; ++i)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            int i;
            cin >> i;
            int df = pr[i + 1] - 2 * pr[i] + pr[i - 1];
            pr[i] += df;
        }
        else
        {
            int i;
            cin >> i;
            int col = pr[i] - pr[i - 1];
            if (col == 0)
            {
                cout << (i - pr[i]) * 2 - (pr[1] == 0);
            }
            else
            {
                cout << pr[i] * 2 - (pr[1] == 1);
            }
            cout << '\n';
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    solve();
}