#include <iostream>
#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;
    for(int i=0; i<n; i++){
        int c; cin>>c;
        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==1) br1++;
                else br0++;
            }

        }
    }
}