#include <bits/stdc++.h>
#define pc pair<int, char>
#define f first
#define s second

using namespace std;

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

    int n;cin>>n;
    int a[n+10];
    int cnt = 0;
    for(int i = 0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]==1)cnt++;
    }
    int q;cin>>q;
    while(q--)
    {
        int t;cin>>t;
        if(t==0)
        {
            int x;cin>>x;
            if(x<=cnt)cout<<"1\n";
            else cout<<"0\n";
        }else
        {
            int x, y;cin>>x>>y;
            if(a[x-1]==1 && y==0)cnt--;
            else if (a[x-1]==0 && y==1)cnt++;
            a[x-1]=y;
        }
    }
    return 0;
}