#include <iostream>
#include <vector>
#define ll long long
using namespace std;

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

    ll n, q, t, k, x; cin>>n;
    ll br1=0, br0=0, br=0;
    vector<int>v(n+1);
    for(int i=1; i<n+1; i++){
        cin>>v[i]; int c=v[i];
        if(c==0) br0++;
        else if(c==1) br1++;
        else br++;
    }
    cin>>q;
    while(q--){
        cin>>t;
        if(t==0){
           cin>>k;
           if(br==0){
                if(k<=br1) cout<<1<<endl;
                else cout<<0<<endl;
           }
        }
        else{
            cin>>k>>x;
            if(br==0){
                if(x==0){
                    if(v[k]==1){br1--; br0++; v[k]=0; }

                }
                else{
                    if(v[k]==0) {br1++; br0--; v[k]=1;}
                }

            }

        }
    }
}