#include <iostream>
#include <unordered_map>
#include <map>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <limits>
#include <algorithm>

//#include <bits/stdc++.h>

/*
bool check(std::vector<std::vector<char>>& p, int u, int v) {
    if (seen[u] || seen[v]) return false;
    seen[u] = true;
    seen[v] = true;
    for (auto it = paths[u].begin(); it != paths[u].end(); it++) {
        char c = it->first;
        std::vector<int> pp = it->second;

        for (int p = 0; p < pp.size(); p++) {
            auto finv = paths[pp[p]][c];
            if (finv.size() > 0) {

                for (int i = 0; i < finv.size(); i++) {

                }
            }
        }
    }
}*/

int main()
{
    std::ios::sync_with_stdio(false);
    /*std::cin.tie(0);
    std::cout.tie(0);*/

    int n;
    std::cin >> n;

    std::vector<int> arr(n);
    int one = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> arr[i];
        if (arr[i] == 1) one++;
    }

    int q;
    std::cin >> q;
    for (int i = 0; i < q; i++) {
        int a, b;
        std::cin >> a >> b;
        b--;
        if (a == 1) {
            int c;
            std::cin >> c;
            if (arr[b] == 1 && c == 0) {
                one--;
                arr[b] = 0;
            }
            else if (arr[b] == 0 && c == 1) {
                one++;
                arr[b] = 1;
            }
            else {
                arr[b] = c;
            }
        }
        else {
            std::cout << ((b+1) <= one) << std::endl;
        }
    }

    return 0;
}