#include <bits/stdc++.h>

using namespace std;

int main()
{   ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    int q;
    cin >> q;

    int t,k,x;

    for(int i=0;i<q;++i){
        cin >> t;
        if(t == 0){
            cin >> k;
            if(k <= counts) cout << 1 << '\n';
            else cout << 0 << '\n';
        }
        else{
            cin >> k >> x;
            if(a[k-1] == 1){
                if(x == 0) counts --;
            }
            else{
                if(x == 1) counts ++;
            }
        }
    }
    return 0;
}